RedditPP Mascot

RedditPP

r/webdev • … • u/Exact_Yak_1323

Typesense for mongo with 3.5million items

I have Typesense running but I'm having issues with searching for something like "culvers burger".

`http://localhost:8080/api/search?q=culvers%20burger`

It will show me a bunch of results for Culver's but none of those results have the word "burger" in them. In fact, it's almost like it got rid of those results altogether. I thought this would have been more plug-n-play, or, better yet, that I would be smart enough to figure this out within 8 hours.

Here are the search parameters I'm using:

const searchParameters = {         q: q,         query_by: 'search_blob',         infix: 'always',         pre_segmented_query: true,         num_typos: 2,         typo_tokens_threshold: 1,         drop_tokens_threshold: 0,         split_join_tokens: 'always',         exhaustive_search: true,         prioritize_exact_match: true,         sort_by: '_text_match:desc'     }

And I'm importing them like:

await typesense.collections().create({         name: 'products',         fields: [             { name: 'code', type: 'string' },             { name: 'product_name', type: 'string', optional: false, index: true, infix: true },             { name: 'generic_name', type: 'string', optional: true, index: true, infix: true },             { name: 'brands', type: 'string', optional: true, index: true, infix: true },             { name: 'search_blob', type: 'string', infix: true }

]     })

and

const item = {             id: doc.code,             code: doc.code,             product_name: doc.product_name,             generic_name: doc.generic_name ?? '',             brands: doc.brands ?? '',             search_blob: `${doc.product_name ?? ''} ${doc.generic_name ?? ''} ${doc.brands ?? ''}`.toLowerCase()         }

I'm not sure what I'm doing wrong or how I could improve my search. Any ideas would be appreciated.

— 0