MongoDB full-text search and tagging

Source: Internet
Author: User

Simple translation.

Original article: http://www.mongodb.org/display/DOCS/Full+Text+Search+in+Mongo

MongoDB adds an array of tags to implement the tag function ).

OBJ = {
Name: "Apollo ",
Text: "Some text about Apollo moon landings ",
Tags: ["moon", "Apollo" "spaceflight",]
}


Index creation:

DB. Articles. ensureindex ({tags: 1 });


Search:

// Search for a document labeled "Apollo" in articles and output the name attribute of the document.

> Print (db. Articles. findone ({tags: "Apollo"}). Name );
Apollo


Full-text search divides all text into a keywords array, which is essentially the same as the tag function:


{Title: "This is fun ",
_ Keywords: ["this", "is", "fun"]
}


Compared with dedicated full-text search engines:

MongoDB is only a built-in function that enables full-text search. It is not a dedicated full-text search engine.

The dedicated full-text search engine provides the following features:

1. Word Segmentation

2. Rank query (MongoDB can implement, but you need to writeCode)

3. Bulk index Building

Although bulk index building can quickly create indexes, it cannot achieve real-time results. MongoDB has a great advantage in real-time, and traditional tools are difficult to achieve this effect.


Example:

The Business Insider web site uses MongoDB for its blog search function in production.
Mark Watson's opinions on Java, Ruby, lisp, AI, and the semantic web-a recipe example in ruby.
Full text search with MongoDB at flowdock

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.