Posts

Showing posts with the label mongo-java-driver

Mongo Java Driver searching by text index

Image
Clash Royale CLAN TAG #URR8PPP Mongo Java Driver searching by text index In mongo's java driver I am using $text then $search to find things in a document however, this seems to not always yield the right results such as sometimes it will return items that don't have the searched for string. Is there a reason for this? ANSWER You can just escape the string and mongo won't use the delimiters. Example: {"$text" : {"$search" : ""<insert term here>""}} {"$text" : {"$search" : ""<insert term here>""}} 1 Answer 1 As a quick preliminary note: You should generally give some more details and examples around your specific problem. However, this one can probably be answered without that. ;) You are dealing with a text (!) index here. That means that there is quite some work done on the MongoDB server side wh...