#community-help

Understanding Typesense's Synonym Functionality

TLDR Blake was having trouble getting partial matches when searching for synonyms in Typesense. Kishore Nallan suggested using an array field for alternative names instead of synonyms.

Powered by Struct AI

1

5
9mo
Solved
Join the chat
Jan 23, 2023 (9 months ago)
Blake
Photo of md5-e18fd6bf1ed8f3adba05f7061edef1e1
Blake
09:00 AM
Hi, new to Typesense and love it so far: straight forward to get started, great documentation. I've managed to create a Collection and uploaded some Documents. The Documents are ingredients, and each ingredient has multiple names one of which is the preferred name. The Document schema includes a field called name, which is the preferred name. I then create Synonyms using the other names and upsert them to Typesense. When I search using the preferred name it works perfectly, including for partial strings. However, when I search using the Synonym I have to type the complete name for a result to be returned. For example, propolis has a Synonym bee bread. Searching "pro" will return propolis as expected. However, searching for bee returns no results, similarly bread also returns no results. Is this how Synonyms are intended to work? My expectation was that a partial search string should return potentially matching synonyms.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:12 AM
👋 happy to hear that you are liking Typesense!

Regarding synonyms, yes, they don't have typos enabled because typically we have found that to get really confusing and saw various corner cases.

What you could do here is to index these alternative names as an array field and include this field during searching.
Blake
Photo of md5-e18fd6bf1ed8f3adba05f7061edef1e1
Blake
09:13 AM
Excellent, I thought that was the answer
09:13
Blake
09:13 AM
Thanks so much for the prompt reply!

1

09:13
Blake
09:13 AM
I'll give it a go a bit later