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!