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” },
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.