I have a full-text index in MongoDB and need to search only on top of a field, rather than all. Anyone know if this is possible?
I have a full-text index in MongoDB and need to search only on top of a field, rather than all. Anyone know if this is possible?
According to MongoDB documentation , it supports the indexing and search of text from the version 2.4, if enabled. As of version 2.6, this feature is available by default.
To create a text index, do:
db.reviews.ensureIndex( { comments: "text" } )
The text indexing engine supports several languages, listed here .
To perform the search, use the $text
operator, whose syntax is:
{ $text: { $search: <string>, $language: <string> } }
I do not have good knowledge on MongoDB, but this link will help you in detail.