Finding a value in a specific field in MongoDB Full Text Search

(Full Text MongoDB Search)

Hello, I put some fields in the index, and here is how I could search for search_keyword .

BasicDBObject search = new BasicDBObject("$search", "search_keyword"); 
BasicDBObject textSearch = new BasicDBObject("$text", search);

DBCursor cursor = users.find(textSearch);

I do not want to search search_keyword in all fields specified in the index. * Is there a way to specify search_keyword to search in specific fields from the index ?? *

If yes, please give me some idea on how to do this in Java .

Thank.

+4
source share
1 answer

, . , companyName. $text , companyName, .

, $text . , . $text , $text. regex.

MongoDB , , , . ElasticSearch . .

+11

Source: https://habr.com/ru/post/1547618/


All Articles