How does MongoDB text search work?
I create a new collection test_index and insert two documents:
var mydocs = [
{t: "Her", language: "english"},
{t: "El asaltante", language: "spanish"}
]
db.test_index.insert(mydocs)
Create a text index for the field t
:
db.test_index.ensureIndex({"t": "text"})
Do a search:
db.test_index.find({$text: {$search: "asaltante"}})
No results are returned.
Instead, if I use $ text like this, it works.
db.test_index.find({$text: {$search: "asaltante", $language: "spanish"}})
Is this an intentional use? Should I do $ 10 text searches if I have 10 translations. This sounds ineffective. How does MongoDB's $ text $ search engine work?
+3
source to share
No one has answered this question yet
See similar questions:
or similar: