How to use queryString with date range and filter?

I have a complex searchs like AND, OR, NOT. I came across the documentation and find compound operators like should, must, mustnot which is equal to AND, OR, NOT.

Now I got to know about queryString can anybody tells me what’s the major difference between these two.

Also, I have these fields in the collection:

    "_id" : ObjectId("6419ccd559e822b43c3e7dce"),
    "articleid" : "155052228",
    "headline" : " the largest airline in India, unveiled a revolutionary three-point",
    "fulltext" : "#IndiGo, the largest airline in India, unveiled a revolutionary three-point disembarkation procedure that will let…",
    "pubdate" : "2022-08-06 02:31:41",
    "article_type" : "online",
    "clientidArray" : [
    "pubdateRange" : ISODate("2022-08-06T02:31:41.000+0000")

So I need to fetch data by - daterange using “pubdateRange” field then “clientidArray” and then I will use must and should to search a keyword or text in 2 fields i.e. - healine and fulltext.

According to you what should be ideal solution queryString or this compound operators.

Hi @Utsav_Upadhyay2

There is no logical difference between the compound operators and the queryString operators in the MongoDB Atlas Search.
The difference lies in the way the queries are written in both the operators, where the compound operators map to the AND OR and NOT logical operators, the queryString makes direct use of these operators.

The examples in the documentation clearly mentions the usage of the queryString operators in the Altas search query.

Could you help me with the query that you have tried using both the operators with the response that you have received?


I don’t know how to make a query with range and filter using queryString!

    "headline":"T20 World Cup: Zomato’s Epic Response To Careem Pakistan’s ‘Cheat Day’ Remark Is Unmissable",
    "fulltext":"The trade began on October 21</p><p>Ever for the reason that starting of the T20 world cup, Twitter has been flooded with memes and commentary. Now, Zomato and Careem Pakistan’s tongue-in-cheek trade on Twitter.",
    "headline":"Apple Wants to Drop ‘Hey' From the ‘Hey Siri' Wake Phrase for Voice Commands: Report",
    "fulltext":"Apple is said to be working on changing the wake phrase for its Siri voice assistant, and will change the phrase from ‘Hey Siri' to simply ‘Siri'.",

So, above is the data sample doc.

by Using queryString, I need to find the data in the field - fulltext, by filtering clientArray and with range pubdateRange.
How will I do this with queryString?

Hi @Utsav_Upadhyay2

Could you please clarify if the examples provided in the documentation are not clear enough for you to understand? If not, do you have any suggestions for more detailed examples to help you better comprehend the topic?

Additionally, regarding the sample document you shared, could you please provide more information about the query you attempted to run and any errors that occurred during its execution?


There is no example in the document of range and filter with queryString. so, I am looking for a solution where I can apply range, filter and queryString in Atlas search query.

Could you please guide me how can I add filter and range (daterange) in below query ?

      $search: {
         "queryString": {
            "defaultPath": "fullplot",
            "query": "plot:(captain OR kirk) AND enterprise"