MongoDB Full Text Search

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.