Do synonyms chain?

We've spotted some unusual behaviour when using synonyms, and I just wanted to confirm whether we've found a bug or a feature :slight_smile:

We've a synonym list that contains something like this
dog, pet
pet, cat
cat, kitten

and we are seeing synonym matches of cat and kitten when searching for dog. Is it expected behaviour for elastic to chain the synonyms together? Is there a way to enforce a strict single synonym match?

Robbo, could you provide your full index mapping, please?

Are you doing synonym expansion at indexing or search time, or both? If it's the latter I can see how "dog" could match "cat" via "pet", but "kitten" is a bit trickier. (Doing expansion at both index and search time isn't recommended.)

Robbo—

Yes you’re actually representing a hypernym / hyponym relationship here.
“cat” is a type of “pet”.

I might recommend this series of blog articles,

The advice here is somewhat complicated by the new SynonymQuery (this
article is on Solr but same advice applies to both)

This is an extremely complex topic with a lot of “it depends” involved.

Best
Doug

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.