Aggregation pipeline with $match: { $text }, $sort, $facet with $project gives an error

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 8.2.3
    • Component/s: None
    • None
    • ALL
    • Hide

      1. db.collection("test").insertOne({foo: "Hello, World!"})
      2. {{db.collection("test").createIndex({foo: "text"})
      }}

      And they try the given aggregation query from the description.

      Show
      1. db.collection("test").insertOne({foo: "Hello, World!"}) 2. {{db.collection("test").createIndex({foo: "text"}) }} And they try the given aggregation query from the description.
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I'm getting an hard error:

      Consider using $getField or $setField for a field path with '.' or '$'. :: caused by :: FieldPath field names may not start with '$', given '$computed0'.

      When trying the following aggregation query:

      [
        {
          $match:
            /**
             * query: The query in MQL.
             */
            {
              $text: {
                $search: "Hello"
              }
            }
        },
        {
          $sort:
            /**
             * Provide any number of field/order pairs.
             */
            {
              score: {
                $meta: "textScore"
              }
            }
        },
        {
          $facet:
            /**
             * outputFieldN: The first output field.
             * stageN: The first aggregation stage.
             */
            {
              results: [
                {
                  $skip: 0
                },
                {
                  $limit: 100
                },
                {
                  $project: {
                    foo: true
                  }
                }
              ],
              metadata: [
                {
                  $count: "total"
                }
              ]
            }
        }
      ]

      On a simple collection with a text index. It works if I remove the $project phase, it doesn't give such an error

            Assignee:
            Unassigned
            Reporter:
            Segev Finer
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: