Database Reference
In-Depth Information
{
"queryDebugString" : "fish||||||",
"language" : "english",
"results" : [
{
"score" : 0.75,
"obj" : {
"_id" : ObjectId("51d7ccb36bc6f959debe5514"),
"number" : 1,
"body" : "i like fish",
"about" : "food"
}
},
{
"score" : 0.6666666666666666,
"obj" : {
"_id" : ObjectId("51d7ccb36bc6f959debe5516"),
"number" : 3,
"body" : "i like to go fishing",
"about" : "recreation"
}
}
],
"stats" : {
"nscanned" : 2,
"nscannedObjects" : 0,
"n" : 2,
"nfound" : 2,
"timeMicros" : 112
},
"ok" : 1
}
Now let's examine some other text search features that we can use to enhance our text queries.
Filtering Text Queries
The first thing we can do is to filter the text queries. To refine our fish query, let's say we only want documents that
refer to fish as food, and not any that match “fishing” the activity. To add this additional parameter, we use the filter
option and provide a document with a normal query. So in order to find our fish as food, we run the following:
> db.texttest.runCommand( "text", { search : "fish", filter : { about : "food" } })
{
"queryDebugString" : "fish||||||",
"language" : "english",
"results" : [
{
"score" : 0.75,
"obj" : {
"_id" : ObjectId("51d7ccb36bc6f959debe5514"),
"number" : 1,
 
Search WWH ::




Custom Search