0

I have the fol docs:

db.docs.insert({_id:1, title:"make: aaa, model: 12"})
db.docs.insert({_id:2, title:"make: bab, model: 1"})
db.docs.insert({_id:3, title:"make: bab, model: 12"})

I search for bab 12 and need mongo to return me only doc #3. Unforturnately I cannot find a suitable query.
Obviously db.docs.find( { $text: { $search: "bab 12" } } ) returns all 3 docs
and db.docs.find( { $text: { $search: "\"bab 12\"" } } ) returns nothing.

Is there a way to do this, without regex (which is too slow - I have millions of docs in docs collection)?

avalanche1
  • 3,154
  • 1
  • 31
  • 38
  • That's exactly what the linked dupe is asking as well. Note that each word is separately quoted. – JohnnyHK Oct 20 '16 at 14:32
  • Wowa, really! I tried it with quoting both words separately and it worked! Thank you, sir, you've opened my eyes) – avalanche1 Oct 20 '16 at 14:36

0 Answers0