Database Reference
In-Depth Information
Currently text search supports the following languages.
Danish
Dutch
English
Finnish
French
German
Hungarian
Italian
Norwegian
Portuguese
Romanian
Russian
Spanish
Swedish
Turkish
For more details on what is currently supported within MongoDB's text search, see the page
http://docs.mongodb.org/manual/reference/command/text/ .
Text Indexes in Other Languages
We originally created a simple text index earlier in order to get started with our text work. But there are a number of
additional techniques you can use to make your text index better suited to your workload. You may recall from earlier
that the logic for how words are stemmed will change based on the language that MongoDB uses to perform it. By
default, all indexes are created in English, but this is not suitable for many people as their data may not be in English
and thus the rules for language are different. You can specify the language to be used within each query, but that isn't
exactly friendly when you know which language you are using. You can specify the default language by adding that
option to the index creation:
db. texttest.ensureIndex( { content : "text" }, { default_language : "french" } );
This will create a text index with the French language as the default. Now remember that you can only have one
text index per collection, so you will need to drop any other indexes before creating this one.
But what if we have multiple languages in one collection? The text index feature offers a solution, but it
requires you to tag all your documents with the correct language. You may think it would be better for MongoDB
to determine which language a given document is in, but there is no programmatic way to make an exact linguistic
match. Instead, MongoDB allows you to work with documents that specify their own language. For example, take
the following four documents:
{ _id : 1, content : "cheese", lingvo : "english" }
{ _id : 2, content : "fromage", lingvo: "french" }
{ _id : 3, content : "queso", lingvo: "spanish" }
{ _id : 4, content : "ost", lingvo: "swedish" }
 
Search WWH ::




Custom Search