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