MongoDb text search does not return result

I have the following request

db.Profiles.find({ "$text" : { "$search" : "vk" } }) 

This gives me the following result:

 { "_id" : ObjectId("55e999a5bd1f3926586799bb"), "created" : ISODate("2015-09-04T13:16:21.555Z"), "userId" : 4790, "email" : " vk@mydomain.com ", "firstName" : "", "lastName" : "", "phoneNumber" : "", "isUnsubscribed" : false, "isAboveLimit" : true, "status" : 0, "userAgent" : 0, "isDeleted" : false, "p2l" : [ { "listId" : 31613, "status" : 25, "subscriptionDate" : ISODate("2015-09-17T14:04:33.660Z") } ], "countryId" : 0, "cf" : [] } 

But the following:

 db.Profiles.find({ "$text" : { "$search" : "v" }}) 

No results.

+6
source share
1 answer

From the documentation :

The $text operator matches the full phrase. Therefore, if the document field contains the word blueberry, a search for the term blue will not match. However, blueberries or blueberries will match.

If you want to find entries containing v in the email field, you can run $regex match:

 db.Profiles.find({ "email" : { "$regex" : /v/ } }) 
+4
source

All Articles