Database Reference
In-Depth Information
"n" : 1,
"nfound" : 1,
"timeMicros" : 150
},
"ok" : 1
}
Notice first that the
queryDebugString
contains both
cook
and
lunch
, as these are the search terms we were
using. Also note that two entries were scanned, but only one was returned. The search works by first finding all
matches and then eliminating nonmatches.
The last search function that people may find valuable is
string literal searching
, which can be used to match
specific words or phrases without stemming. As it stands, all the elements of our individual searches are being
tokenized and then stemmed and each term evaluated. Take the following query:
> db.texttest.runCommand( "text", { search : "mongodb text search" })
{
"queryDebugString" : "mongodb|search|text||||||",
"language" : "english",
"results" : [
{
"score" : 3.875,
"obj" : {
"_id" : ObjectId("51d7ccb36bc6f959debe551a"),
"number" : 7,
"body" : "i like mongodb text search",
"about" : "food"
}
},
{
"score" : 3.8000000000000003,
"obj" : {
"_id" : ObjectId("51d7ccb36bc6f959debe551b"),
"number" : 8,
"body" : "mongodb has a new text search feature",
"about" : "food"
}
}
],
"stats" : {
"nscanned" : 6,
"nscannedObjects" : 0,
"n" : 2,
"nfound" : 2,
"timeMicros" : 537
},
"ok" : 1
}