I am running mongodb v2.4.5. I have a document with the following fields:
{ "_id" : ObjectId("<someid>"), temp:"python", github_repo_languages" : { "python" : 17, "java" : 984 } }
If I run the query:
db.users.runCommand( "text", { search: "java" })
{
"queryDebugString" : "java||||||",
"language" : "english",
"results" : [ ],
"stats" : {
"nscanned" : 0,
"nscannedObjects" : 0,
"n" : 0,
"nfound" : 0,
"timeMicros" : 97
},
"ok" : 1
}
mongodb doesn't find any documents.
Here are my indexes:
> db.users.getIndexes()
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "workingon.users",
"name" : "_id_"
},
{
"v" : 1,
"key" : {
"_fts" : "text",
"_ftsx" : 1
},
"ns" : "workingon.users",
"name" : "users_text_index",
"weights" : {
"$**" : 1
},
"default_language" : "english",
"language_override" : "language",
"textIndexVersion" : 1
}
]
Other searches work for simple text fields. Is the issue the complex json object? Are there plans to add complex json objects?
According to the documentation ( http://docs.mongodb.org/manual/core/text-search/ ) the text index should be on the field or fields whose value is a string or an array of string elements. So as you pointed out, the json field will not work.