We are in the process of migrating from couchbase to MongoDB, One of the couchbase db query is written in Free Text search with complex aggregation. I am trying to convert the query. I could n’t find any AND operator can be used in free text search. I have created the compound index for 4 fields. The OR conditonal operator is working fine. But i am looking for AND operator. Is that anyway i can achieve it? So that data will be scrutinized.
$text: { $search: “100063011 e-com NLP-PromotionalScanner c23222-4840-44ec-a0ce-6b643e09” },
Skip to main content
16 days later
Hi @Rajesh_Gurusamy and welcome to the community forum.
Can you help in understanding what do you mean by “Free Text Search”.
To help you with a response for your use case, could you help me with some sample data from the collection and the expectation from the aggregation query.
Also, to use AND and OR in Atals Serach, you can make use of the must
, mustNot
, should
, and filter
clause as mentioned in the compound operator in MongoDB.
Regards
Aasawari
Hi, There is no way to do this with $text indexes - you need to use a full text search engine like Atlas Search. You can only us a single $text expression in a non Atlas query and so cannot use things like $and.
New & Unread Topics
Topic | Replies | Views | Activity |
---|---|---|---|
Mongodb Slow query group(profiler) | 2 | 359 | May 2024 |
Sorting behavior and sorting sequence for mongodb | 3 | 469 | Jun 2024 |
updating data from my meal database | 1 | 243 | Jul 2024 |
Mysterious loss of data, in a very strange manner. | 5 | 70 | Dec 2024 |
How should i handle daily updates of thousands of records while now knowing which ones actually changes? | 0 | 26 | Feb 9 |