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

$or queries with text indexes fail on clustered collections

    • Query Integration
    • Fully Compatible
    • ALL
    • QI 2023-04-03, QI 2023-04-17, QI 2023-05-15, QI 2023-05-29, QI 2023-06-12, QI 2023-06-26

      It appears that using $or to query both _id and a text index do not work together.

      See this example:

      db.createCollection('c', {clusteredIndex: {key: {_id: 1}, unique: true}})
      db.c.createIndex({b: "text"})
      db.c.insert({b: "foo"}
      db.c.find({$or: [{$text: {$search: "foo"}}, {_id: 1}]})
      

      This fails with the following error:

      error processing query: ns=test.cTree: $or
          _id $eq 1
          TEXT : query=foo, language=english, caseSensitive=0, diacriticSensitive=0, tag=NULL
      Sort: {}
      Proj: {}
       planner returned error :: caused by :: Failed to produce a solution for TEXT under OR - other non-TEXT clauses under OR have to be indexed as well.
      

            Assignee:
            gil.alon@mongodb.com Gil Alon
            Reporter:
            louis.williams@mongodb.com Louis Williams
            Votes:
            0 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved: