query icon indicating copy to clipboard operation
query copied to clipboard

Query by nested fields does not work

Open pavvell opened this issue 1 year ago • 0 comments

hi! it seems that the library supports creating indexes on nested fields, but in reality I can't make it work.

for example, I have records like this:

{ productId: 'product-1',  data: { name: 'name of the product', productId: 'product-1', score: 1 } }

If I create index on a nested field:

const nestedIndex = productsCollection.createIndex({
        name: "nested_products_ids_index",
        terms: ["data.productId"],
    });

I get 0 results when I query it:

const queryProducts = await productsCollectionIndex.match({
        "data.productId": ['product-1'],
    })

but if I create index using only productId on the top level, it works:

const productsCollectionIndex = productsCollection.createIndex({
        name: "products_ids_index",
        terms: ["productId"],
    });

I get the results. is it supposed to work this way, and nested fields are not supported or is this is a bug? thanks!

pavvell avatar Feb 07 '24 16:02 pavvell