Terms Query equivalent?

I’m looking for ES Terms query equivalent. I want to fetch documents with array of terms from another index. Is it possible? This saves me from querying list of following page IDs and then find all the post with IDs from posts index.

On related note, how do I filter documents with array of filter values (javascript sdk)?
Eg, here is how I’m saving posts:

posts index:
[
 { objectID: 123,
   pageId: 1
 },
{
  objectID: 124,
  pageId: 2
}
]

search documents with pageId: [1,2]

1 Like

What you’re looking are Algolia’s filtering capabilities. In your case, because pageId is a numerical attribute, you can just achieve it with the following query parameter:

filters:pageId=1 OR pageId=2`

Ah pageId is not numeric, it was just an example. So I have to concat to build a string. Otherwise not possible to pass it from another index like Terms query without fetching the Ids in client?

If the attribute you want to filter on is not a numeric, you can add it to the attributesForFaceting index settings (equivalent to the terms aggregation in ES) in order to use the facet filtering capability.

filters: "myattr:myval1 OR myattr:myval2"

It’s not possible to “pass it from another index”, you need to add the data you want to filter on on all the records.

1 Like