Quantcast
Channel: Weaviate Community Forum - Latest posts
Viewing all articles
Browse latest Browse all 3588

How can I batch query by id when using JS/TS v3?

$
0
0

Is there a recommended way to query for multiple objects, based on their id, when using the JS/TS v3 client?

I see that I can query against a single id as follows:

const jeopardy = client.collections.get('JeopardyQuestion')
const response = await jeopardy.query.fetchObjectById('ed89d9e7-4c9d-4a6a-8d20-095cb0026f54')

However, I need to retrieve large batches; I can’t use a one-query-per-object approach.

I tried using fetchObjects and filters, using variations on something like this:

const result = await jeopardy.query.fetchObjects({
  filters: jeopardy.filter.byProperty('id').containsAny(["id1", "id2"])
})

But either the ‘id’ property cannot be accessed this way, or it must have a different name than either ‘id’, ‘uuid’, or ‘_additional.id’.

I saw this related question, which provided an approach for Python: Best way to query objects using id at once

But, it seems like the JS/TS v3 sdk cannot be used in this way. I suppose I can look at just POSTing the graphql queries myself, though naturally I prefer the uniformity of using the JS/TS v3 client, and it seems like it should have this functionality.

Is there a recommended way to query for multiple objects, based on their id, when using the JS/TS v3 client?


Viewing all articles
Browse latest Browse all 3588

Trending Articles