Related article: PHP uses Coreseek for full-text indexing
Introduction
Mongo provides some functionality that's useful for text search and tagging.
MongoDB provides some features that are owned for full-text search and tagging.
Multikeys (indexing values in an array) multi-built (indexed value in array)
The Mongo Multikey feature can automatically index arrays of values. Tagging is a good example of where this feature is useful. Suppose you has an article object/document which are tagged with some category names:
obj = { name : "Apollo" , Text: "Some text about Apollo moon landings" , //body Tags: [ "moon" , "Apollo" , "spaceflight" //index tag }
And that this object was stored in Db.articles. The command
Db.articles.ensureIndex ({tags:1});
Would index all the tags in the document, and create index entries for "Moon", "Apollo" and "spaceflight" for that document .
Index Use Example
These items on the usual-in:
> Print(db. Articles. FindOne({ tags:"Apollo"}). Name);
Apollo
The database creates an index entry for each item in the array. Note an array with many elements (hundreds or thousands) can make inserts very expensive. (Although for the example above, alternate implementations is equally expensive.)
Text Search
It is fairly easy to implement basic full text search using Multikeys. What we recommend are have a field that have all of the keywords in it, something like:
{: ' This was fun',:["This","was","Fun"]}
Your code must split the title above into the keywords before saving. Note that this code (which are not part of Mongo DB) could do stemming, etc. too. (Perhaps someone in the community would-like-to-write a standard module, that does this ...)
Related article: PHP uses Coreseek for full-text indexing
Reprint Please specify: Fkblog»mongodb full-text index (http://www.fkblog.org/blog485)
MongoDB Full-Text index