Is filter+nearVector+offser-limit not supported ts v3?

The problem I am facing is that I currently have only 30 elements in my database, and I want to retrieve them in a paginated way (9 elements per page).

What I observe in my logs is the following:

  • On the first page (offset = 0), I receive 9 different elements, as expected.
  • On the second page (offset = 9), I receive the exact same 9 elements as in the first page.
  • The same happens on the third page (offset = 18), returning the same 9 elements again.
  • On the fourth page (offset = 27), I receive only the last 3 elements (of the 9 before).

If we do the math, 3 * 9 + 3 = 30, which matches the total number of elements in the database, so it seems that pagination is partially working. However, I do not understand why the properties of the elements are always the same across pages if the pagination is functioning correctly.

I tested the same query using the Weaviate console, and it works as expected there. However, when I run it in my TypeScript code, I encounter this issue.

I would appreciate any guidance on how to resolve this, or at least a confirmation on whether what I am trying to do is supported.

here is my code:

try {
    const client = await weaviate.connectToWeaviateCloud(config.WEAVIATE_URL, {
      authCredentials: new weaviate.ApiKey(config.WEAVIATE_API_KEY),
    });

    // Verificar que la conexión esté lista
    if (!client.isReady()) {
      throw new Error("No se pudo conectar a Weaviate");
    }

    let collection;
    try {
      collection = client.collections.get("FashionItem");
    } catch (error) {
      console.log("No results found, weaviate FashionItem is inicilized");
      return [];
    }

    let offset = page * limit;
    console.log("offset", offset);
    const queryOptions: any = {
      filters: client.collections
        .get("FashionItem")
        .filter.byProperty("embedding_type")
        .equal("text"),
      returnProperties: [
        "name",
        "description",
        "image_url",
        "url",
        "brand",
        "price",
        "embedding_type",
      ],
      limit: limit,
      offset: offset,
    };

    const result = await collection.query.nearVector(queryVector, queryOptions);

thaks!

hi @MELINA_BELEN_JAUREGU !!

Welcome to our community :hugs: !

The properties that Weaviate will return back for the query are defined by returnProperties and will not change according to pagination.

Once you do a Vector Search, it will return all objects, being the first one the most relevant to your vector query.

For each object, it will bring all properties of those properties, according to what is passed with returnProperties

Let me know if this was your question, otherwise, feel free to provide some examples.

Thanks!

filters: client.collections
        .get("FashionItem")
        .filter.byProperty("embedding_type")
        .equal("text"),

I changed it for:
const filters =collection.filter.byProperty("embedding_type").equal("text");

and that did work well.

also for multiple filters:

const filters = Filters.and(
          collection.filter.byProperty("embedding_type").equal("text"),
          collection.filter.byProperty("brand").equal(brand)
        )

It was a syntax problem.

1 Like

Thanks for sharing!

By the way, you can also do:
weaviate.filter.byProperty('text').equal('two')

THanks!

1 Like