Range operator on ObjectId, string

Currently, some methods of pagination in atlas search are difficult due to the limitations available operators. By this I mean that it is difficult to implement a keyset or cursor based pagination using object id’s.

In keyset pagination, you use filtering instead of skip + limit. To use this in Atlas Search, you might do a query like the following, where you know the _id from the previous set of results:

{
  compound: {
    must: {
        text: {
            path: "..."
            query: "my search query" 
        }
    },
    filter: {
        range: {
            path: "_id",
            gt: ObjectId('...')
        }
    }
  }
}

To make this possible, it would be great if we could use the range operator with more data types, like objectid and strings.

1 Like