Skip to content

You are viewing docs for an old version. Switch to latest v30.2.

Synonyms ​

The synonyms feature allows you to define search terms that should be considered equivalent. For eg: when you define a synonym for sneaker as shoe, searching for sneaker will now return all records with the word shoe in them, in addition to records with the word sneaker.

Typesense supports two types of synonyms:

  1. Multi-way synonyms: Defining words ABC, DEF and XYZ (for eg) as multi-way synonyms will cause searches for any one of those words (eg: DEF) to return records containing at least one of the words in the synonym set (eg: records with ABC or DEF or KYX are returned).

  2. One-way synonyms: Defining the words DEF and XYZ as one-way synonyms of ABC will cause searches for DEF or XYZ to return records containing ABC.

Create or update a synonym ​

Multi-way synonym ​

Sample Response ​

One-way synonym ​

Sample Response ​

Definition ​

PUT ${TYPESENSE_HOST}/collections/:collection/synonyms/:id

Arguments ​

ParameterRequiredDescription
synonymsyesArray of words that should be considered as synonyms.
rootnoFor 1-way synonyms, indicates the root word that words in the synonyms parameter map to.

Retrieve a synonym ​

We can retrieve a single synonym.

Sample Response ​

Definition ​

GET ${TYPESENSE_HOST}/collections/:collection/synonyms/:id

List all synonyms ​

List all synonyms associated with a given collection.

Sample Response ​

Definition ​

GET ${TYPESENSE_HOST}/collections/:collection/synonyms

Delete a synonym ​

Delete a synonym associated with a collection.

Sample Response ​

Definition ​

DELETE ${TYPESENSE_HOST}/collections/:collection/synonyms/:id

You are viewing docs for an old version. Switch to latest v30.2.