Issue with Query Hangs Identifying Different Collection Field Names
TLDR Kanak experiences query hangs when collection field names differ. Ahmed had an issue adding documents to collections, which was self-resolved. Kishore Nallan resolved Kanak's issue with the updated build.
Jul 28, 2023 (4 months ago)
Kanak
08:05 PMAs I was moving around the parameters and running filters, some queries were hanging. I think maybe I've narrowed it down to this: queries are hanging when the collection being queried (eg: Products) is being referenced by a different name in the referencing collection. Eg: if I use the field schema
{ name: "product", type: "string", reference: "Products.product_id" }
, searching for Products is hanging if I use a $CustomerProductPrices filter_by clause (User searches work fine with the filter though). Same if I change user_id to user in the referencing schema - searches on User hang, while searches on Products work fine. If product_id in Products is referenced _as product_id in CustomerProductPrices, and user_id in Users is referenced as user_id in CustomerProductPrices, queries all seem to be working.
Kanak
08:08 PMconst array = (length, items) => Array(length).fill(0).map(items);
await client.collections().create({
name: "Products",
fields: [
{ name: "product_idx", type: "string" },
{ name: "product_name", type: "string" },
],
});
await client.collections().create({
name: "Users",
fields: [
{ name: "user_id", type: "string" },
{ name: "user_name", type: "string" },
],
});
await client.collections().create({
name: "CustomerProductPrices",
fields: [
{ name: "user_id", type: "string", reference: "Users.user_id" },
{ name: "product_id", type: "string", reference: "Products.product_idx" },
{ name: "product_price", type: "float" },
],
});
let products = array(200, () => ({
product_idx: chance.guid(),
product_name: chance.sentence({
words: chance.integer({ min: 1, max: 10 }),
}),
}));
let users = array(200, () => ({
user_id: chance.guid(),
user_name: chance.word(),
}));
let customers = array(200, () => ({
user_id: users[chance.integer({ min: 0, max: users.length - 1 })].user_id,
product_id:
products[chance.integer({ min: 0, max: products.length - 1 })].product_idx,
product_price: chance.floating({ fixed: 2, min: 1 }),
}));
await client
.collections("Products")
.documents()
.import(products, { action: "create" });
await client
.collections("Users")
.documents()
.import(users, { action: "create" });
await client
.collections("CustomerProductPrices")
.documents()
.import(customers, { action: "create" });
let result = await client
.collections("Products")
.documents()
.search({
q: "*",
filter_by: `$CustomerProductPrices(user_id:=${customers[0].user_id})`,
include_fields: `$CustomerProductPrices(product_price)`,
});
As is, this query is hanging. If I change "product_idx" to "product_id" (so that referencing field matches), or if I change the collection being searched to "Users", the query works fine.
Ahmed
09:16 PMError importing document: Field `category_id_sequence_id` has been declared in the schema, but is not found in the document
field name is category_id for both collections
Ahmed
09:55 PMJul 31, 2023 (4 months ago)
Kishore Nallan
10:34 AMTypesense
Indexed 3005 threads (79% resolved)
Similar Threads
Troubleshooting Typesense API Sorting Error in Item Collections
Nikhil encountered a sorting error when using Typesense API due to an optional reference field in the items collection schema. Harpreet and Jason helped debug and identified a bug with sorting in general for 2 fields with the first one being the join field, promising a fix in a forthcoming build.
Threading Problem During Multiple Collection Creation and Batch Insertion in Typesense
Johan has a problem with creating multiple collections and batch-inserting documents into Typesense, which is returning results from different collections. Kishore Nallan helps troubleshoot the issue and suggests a potential local race condition, which is fixed in a later build.
Cold Start Problem with Dynamic Collections
Adrian reported cold start issues with dynamic collections. Jason suggested using wildcard `*` for query_by parameters, upgrading to `0.25.0.rc34`, and clarified conventions. Adrian's issues were resolved but they reported a limitation that will potentially be addressed.