Query using search using an array of objectIDs

I would like to ask if I can use search (and not get_objects) to retrieve a list of records given their objectID’s? The reason why we would like to use search is because we would like to use facets, filters etc, and most important reuse our existing code.

Best Regards

Jens

Hi Jens,

Indeed you should be able to search for an array of values using filters.
If you’re using the algoliasearch javascript client for example, you can define the following query :

index
  .search("", {
    filters: `objectID:440712660 OR objectID:440712390`
  })

Or if using facetFilters :

index
  .search("", {
    facetFilters: [["objectID:440712660", "objectID:440712390"]]
  })

I hope this helps !

Cheers

Thanks Vincent. Just what I needed

Hi Vincent,
I am using the same way by creating the url like-
https:///listings?q=&idx=content_index&p=0&dFR[objectID][0]=387&dFR[objectID][1]=386

It created the facetFilters. Now have implemented the routing for searches. So the url changed from:
https:///listings?q=&idx=content_index&p=0&dFR%5Bgenres.name%5D%5B0%5D=Comedy
to-
http:///listings?genres=Comedy

But cant figure out how to reconstruct the above url.

Regards.

2 Likes