How to use date range in MongoDB aggregation?

I’m using this Atlas search pipeline in my query aggregation, but it gets every document in my database. I want to apply a date range in this pipeline to get documents on a specific date . But didn’t know how to manage the origin field. Any help, please?

[
    {
        "$search": {
            "index": "TextIndex",
            "compound": {
                "must": [
                    {
                        "near": {
                            "path": "adt",
                            "origin": datetime.datetime(2023, 3, 27, 3, 6, 14, 716199),
                            "pivot": 60000,
                            "score": {"boost": {"value": 1000000000}},
                        }
                    },
                    {"equals": {"path": "st", "value": 2}},
                    {"equals": {"path": "cnf.st", "value": 1}},
                    {"exists": {"path": "att.path"}},
                ]
            },
            "highlight": {"path": "msg"},
        }
    },
    {
        "$project": {
            "_id": 1,
            "aactual_time": 1,
            "time_stamps": 1,
            "data_type": 1
        }
    },
    {"$limit": 20},
]

Hi @ahmad_al_sharbaji - Welcome to the community.

Have you tried looking into the range operator?

If you need further help, please provide sample documents, expected output and index definition. Be sure to include the date range if you provide these examples.

Regards,
Jason

Just an additional note: the pivot option value is used to calculate scores of Atlas Search result documents.

Hope this helps.

Regards,
Jason