Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-13505

Query parser should reject $text predicate in $elemMatch

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: 2.6.0-rc3
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
    • Operating System:
      ALL

      Description

      The query parser should disallow use of $text inside $elemMatch. There is no functionality to match a $text predicate against a subdocument; $text predicates apply to the root of a document only.

      Users receive the following cryptic error message when running an $elemMatch query that contains $text:

      > db.foo.find({a:{$elemMatch:{b:1,$text:{$search:"hello"}}}})
      error: {
      	"$err" : "Unable to execute query: error processing query: ns=test.foo limit=0 skip=0\nTree: a $elemMatch (obj)\n    $and\n        b == 1.0\n        TEXT : query=hello, language=, tag=NULL\nSort: {}\nProj: {}\n planner returned error: failed to use text index to satisfy $text query (if text index is compound, are equality predicates given for all prefix fields?)",
      	"code" : 17007
      }

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: