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

text index with multi-key prefix is not rejected

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.4.0
    • Fix Version/s: 3.5.3
    • Component/s: Text Search
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      > db.a.find()
      > db.a.createIndex({'x.name':'text'})
      {
              "createdCollectionAutomatically" : true,
              "numIndexesBefore" : 1,
              "numIndexesAfter" : 2,
              "ok" : 1
      }
      > db.a.insert({i:1, x:[{name:'pet', language:'en'}, {name:'animal domestique', language:'fr'}]})
      WriteResult({ "nInserted" : 1 })
      > db.a.insert({i:1, x:[{name:'fart', language:'en'}, {name:'pet', language:'fr'}]})
      WriteResult({ "nInserted" : 1 })
      > db.a.insert({i:1, x:[{name:'wax', language:'en'}, {name:'farter', language:'fr'}]})
      WriteResult({ "nInserted" : 1 })
      > db.a.find({$text:{$search:'fart', $language:'fr'}, 'x.language':'fr'})
      { "_id" : ObjectId("584868134fb941395745c6bb"), "i" : 1, "x" : [ { "name" : "wax", "language" : "en" }, { "name" : "farter", "language" : "fr" } ] }
      { "_id" : ObjectId("584867ec4fb941395745c6ba"), "i" : 1, "x" : [ { "name" : "fart", "language" : "en" }, { "name" : "pet", "language" : "fr" } ] }
      > db.a.dropIndexes()
      > db.a.createIndex({'x.language':1, 'x.name': 'text'})
      > db.a.find({'x.language':'fr', $text:{$search: 'fart', $language:'fr'}})
      > db.a.find({'x.language':'fr', $text:{$search: 'fart', $language:'en'}})
      > db.a.find({'x.language':'en', $text:{$search: 'fart', $language:'en'}})
      // empty results
      

      Show
      > db.a.find() > db.a.createIndex({'x.name':'text'}) { "createdCollectionAutomatically" : true, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 } > db.a.insert({i:1, x:[{name:'pet', language:'en'}, {name:'animal domestique', language:'fr'}]}) WriteResult({ "nInserted" : 1 }) > db.a.insert({i:1, x:[{name:'fart', language:'en'}, {name:'pet', language:'fr'}]}) WriteResult({ "nInserted" : 1 }) > db.a.insert({i:1, x:[{name:'wax', language:'en'}, {name:'farter', language:'fr'}]}) WriteResult({ "nInserted" : 1 }) > db.a.find({$text:{$search:'fart', $language:'fr'}, 'x.language':'fr'}) { "_id" : ObjectId("584868134fb941395745c6bb"), "i" : 1, "x" : [ { "name" : "wax", "language" : "en" }, { "name" : "farter", "language" : "fr" } ] } { "_id" : ObjectId("584867ec4fb941395745c6ba"), "i" : 1, "x" : [ { "name" : "fart", "language" : "en" }, { "name" : "pet", "language" : "fr" } ] } > db.a.dropIndexes() > db.a.createIndex({'x.language':1, 'x.name': 'text'}) > db.a.find({'x.language':'fr', $text:{$search: 'fart', $language:'fr'}}) > db.a.find({'x.language':'fr', $text:{$search: 'fart', $language:'en'}}) > db.a.find({'x.language':'en', $text:{$search: 'fart', $language:'en'}}) // empty results
    • Sprint:
      Query 2017-01-23, Query 2017-02-13

      Description

      When doing a AND query between text search and another field, the other field seems ignored

      Below, there should be only one result

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: