Database Reference
In-Depth Information
You are probably wondering how a word like the or it would be stemmed, and what happens if the documents
aren't in English. The answer is that those and similar words would not be stemmed, and MongoDB text search
supports many languages.
The MongoDB text search engine is a proprietary engine written for the MongoDB, Inc. team for text data
retrieval. MongoDB text search also takes advantage of the Snowball string-processing language, which provides
support for the stemming of words and for stop words, those words that aren't to be stemmed, as they don't represent
any valuable concepts in terms of indexing or searching.
The thing to take away from this is that MongoDB's text search is incredibly complex and is designed to be as
flexible and accurate as possible.
Text Search Costs and Limitations
As you can imagine from what you've learned about how text search functions, there are some costs associated with
using MongoDB Text search. The first is that it changes the document storage allocation for future documents to
the usePowerOf2Sizes option, which instructs MongoDB to allocate storage for more efficient re-use of free space.
Second, text indexes are large and can grow very quickly depending on the number of documents you store and the
number of tokens within each indexed field. The third limitation is that building a text index on existing documents
is time-consuming, and it entails adding new entries to a field that has a text index, which is also more costly. Fourth,
like everything in MongoDB, text indexes work better when in RAM. Finally, because of the complexity and size of text
indexes they are currently limited to one per collection.
Enabling Text Search
As mentioned earlier, text search was introduced in MongoDB 2.4 as an experimental or beta feature. As such, you
need to explicitly enable the text search functions on every MongoDB instance (and MongoS if you are sharding)
that will be using this feature in your cluster. There are three ways you can enable text search; the first is to add the
following option to the command you use to start or stop your MongoDB processes:
--setParameter textSearchEnabled=true
The second method is to add the following option to your MongoDB instance's configuration file:
setParameter = textSearchEnabled=true
The third and final method to get text search working on a MongoDB instance is to run the following command
via the Mongo shell:
db.adminCommand({ setParameter: 1, textSearchEnabled : true }
With this set you can now work with the MongoDB full text search features on this node.
the fact that this feature is in beta does not mean it doesn't work. the MongodB, inc. team has put a
considerable amount of effort into trying to get this feature right. By using the feature and reporting any issues you have
on the MongodB, inc. Jira ( jira.mongodb.org ), you can help them get this feature ready for full release.
Note
By now you should have enabled the text search features on your MongoDB instance and are ready to take
advantage of it! Let's look at how to create a text search index and perform text searches.
 
 
Search WWH ::




Custom Search