Weird error from compass on a valid query

Hi,

I ran this query successfully from the atlas search portal - uploadDate is a date type, found in all records:

[
  {
    $search: {
      compound: {
        must: [
          {
            compound: {
              must: [
                {
                  text: {
                    query: "group",
                    path: "documentGroupId",
                  },
                },
                {
                  range: {
                    path: "uploadDate",
                    gt: {
                      $date:
                        "2023-08-14T00:00:00Z",
                    },
                  },
                },
              ],
            },
          },
        ],
      },
      index: "default",
    },
  },
]

when trying to run it in compass on the same database, I get this error:

mongot returned an error :: caused by :: “compound.must[0].compound.must[1].range.gt.type” is required

what does this error mean and how do I resolve it?

Hi @GUY_SOFFER_ZAMRANY1 - Welcome to the community.

I did receive the same error when copying and pasting the same $search stage you provided.

Can you try with the following search query to see if it works in Compass? I changed the gt value to use ISODate():

[
  {
    $search: {
      compound: {
        must: [
          {
            compound: {
              must: [
                {
                  text: {
                    query: "group",
                    path: "documentGroupId",
                  },
                },
                {
                  range: {
                    path: "uploadDate",
                    gt: ISODate("2023-08-14T00:00:00Z"),
                  }
                },
              ]
            }
          }
        ]
      },
      index: "default"
    }
  }
]

I tried the above in my test environment on Compass version 1.40.2 which returned a document successfully both from the embedded mongosh and the Aggregations portion of the Compass UI when filtering for documents.

If that doesn’t work, does it return the same or different error? Additionally, when you state the error is from compass - Is the error from the Aggregation stage in the UI or from the embedded mongosh within Compass? Lastly, please also provide the index definition and sample documents if the above doesn’t help.

Regards,
Jason

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.