Full-text search in mongodb in russian

full-text-search, mongodb

Solution

This is a known limitation of text search as it exists in MongoDB 2.4. For the purposes of text search, MongoDB will treat the each of the characters "ABCDEFGHIJKLMNOPQRSTUVWXYZ" (the "uppercase" set in the POSIX locale) the same as its lowercase equivalent, but it will treat other UTF-8 code points as unique.

Full case-folding support for UTF-8 is to come in a future release; see the associated ticket in JIRA at https://jira.mongodb.org/browse/SERVER-8423.

Problem

I'm trying to use full text search in mongodb: ``` > db.collection.insert({"text" : "Первый второй третий"}) > db.collection.insert({"text" : "первый Второй третий"}) > db.collection.insert({"text" : "первый второй Третий"}) > db.collection.ensureIndex({"text" : "text"}, {"default_language" : "russian"}) ``` Sentences differ only in letter case. ``` > db.collection.runCommand("text" , {search : "первый"}) { "queryDebugString" : "перв||||||", "language" : "russian", "results" : [ { "score" : 0.6666666666666666, "obj" : { "_id" : ObjectId("516acfe2dbfd90a837e09131"), "text" : "первый Второй третий" } }, { "score" : 0.6666666666666666, "obj" : { "_id" : ObjectId("516acfe8dbfd90a837e09132"), "text" : "первый второй Третий" } } ], "stats" : { "nscanned" : 2, "nscannedObjects" : 0, "n" : 2, "nfound" : 2, "timeMicros" : 86 }, "ok" : 1 } ``` The result consists only of two entries but it should be three. In English everything is good.

Original source