1. Full-Text Search concept:
Full-Text search is to establish an index of each word, indicating the number and location of the word in the article, when the user queries, the retrieval program based on the pre-established index to find, and the results of the lookup to the user's retrieval method. (Chinese is not currently supported)
2. Enable full-Text search:
MongoDB starts full-text search by default after the 2.6 version, and if you use the previous version, you need to use the following code to enable full-text indexing:
Db.admincommand ({setparameter:true,textsearchenabled:true})
or use the command:
Mongod--setparameter Textsearchenabled=true
3. Create a full-text index:
Example:db.posts.ensureIndex ({post_text: "text"})
4. Use full-Text indexing:
Example:db.posts.find ({$text: {$search: "w3cschool.cc"}})
5. Delete the full-text index:
Find index Name:db.posts.getIndexes ()
Delete index:db.posts.dropIndex ("Post_text_text")
MongoDB Full Text Search