Compound Query filter by multiple objectId

{
  index: 'userNameCity',
  compound:{
    
    filter:{
      
      equals: {
value: ObjectId [ '6271f2bb79cd80194c81f631', '62cf35ce62effdc429efa9b0' ],
       path: '_id'
  },
   
    }
 ,

The index for the path (_id) is of datatype ObjectID
I want to filter by an array of objectId.
The above code works for single objectId but does not work for array
Note:
The array will be a dynamic list

Can you please suggest

The syntax

is most likely wrong.

Try [ObjectId(‘627…631’),ObjectIs(‘62c…9b0’)]

@steevej Thanks for the suggestion however it does not work

Hi @Manoranjan_Bhol ,

Thanks for your response.

Please note that, values in the equals filter accept either boolean or objectId as a parameter. Please refer to the documentation. Hence you should mention either boolean or ObjectId value only but cannot mention Array or string there.

Thanks,
Darshan

Take a look at https://www.mongodb.com/docs/atlas/atlas-search/compound/, may be you can use it with filter to achieve what you want to do.

@steevej @DarshanJayarama
Thank you for the help again

My goal is to

  • filter by multipls objectId(s)
  • then perform autocomplete search on name, city etc

Hi @Manoranjan_Bhol ,

Thanks for your reply.
Please note that, in index definition If you have created _id with type: objectId then in the equals you can not have more than 1 objectId as that accept either only single objectId in the query.

Further, I have noticed you are mentioning 2 index in the query, that create ambiguity, Do you mind sharing the index definition of this string index.

Thanks,
Darshan

@DarshanJayarama

Please refer to the index defined