Skip to content

Unknown nested fields/wildcards not working (field.*) #15

Description

@maurictg

Hello, I have a very specific situation, but I have no other way to handle it:

This is my schema

import { collection } from 'typesense-ts';

export const productCollection = collection({
    name: 'products',
    fields: [
        { name: 'id', type: 'string' },
        { name: 'title', type: 'string', stem: true },
        { name: 'url', type: 'string' },
        { name: 'price', type: 'int32' },
        { name: 'category_order', type: 'object' },
        { name: 'category_order.*', type: 'int32' }, // <--------------------------------- THIS
        { name: 'photos', type: 'object[]', index: false },
        { name: 'videos', type: 'string[]', index: false },
        { name: 'filters', type: 'object' },
        { name: 'filters.*', type: 'string[]', facet: true } // <--------------------------------- AND THIS
    ],
    enable_nested_fields: true,
});

When trying to do this:

const res = await productCollection.search({ q: '*', query_by: ['title'] });

I will get an error:

Type instantiation is excessively deep and possibly infinite (TS2589)

This happens when I have like 20 more fields than in the example.
The same error occurs to me without nested fields, just having a lot of fields.

I did not find a workaround or other solution for my use-case:

Every product can be in one or more categories. I do not know which, for there are a lot of categories (coming from database).
Using this schema I can sort_by=category_order.1234 (category order might look like this: { 123: 1, 52: 2, 1234: 3 }).

The same applies to filters, it can be any e.g.:

filters.colors-33: ['green', 'blue']

Hopefully you got my point 😅
Fields using fieldname.* wildcards are not working. See Typesense docs: https://typesense.org/docs/30.2/api/collections.html#with-auto-schema-detection

Hopefully this can be fixed or there can be a workaround! I really love this lib, more than the official, for this one doesn't use Axios or any other dependency!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions