Skip to content

Synonyms

If you have mutliple words that mean the same thing, a synonym may be defined to create a relationship between them. It is common for acronyms to be defined as synonyms, for example “New York City” and “NYC” may be defined as synonyms and would mean that a match on either would return the same results. The words “dog” and “puppy” or “cat” and “kitten” are another example where synonyms may be desired. Synonyms are helpful when dealing with industry specific terminology. If you are a Searchcraft Cloud customer, these are managed through the Vektron UI. For self-hosted customers, these are managed via the API.

API Endpoints

  • GET /index/:index/synonyms Returns the synonyms for an index.
  • POST /index/:index/synonyms Add synonyms to an index.
  • DELETE /index/:index/synonyms Delete an array of synonyms from an index.
  • DELETE /index/:index/synonyms/all Delete all synonyms from an index.
    • No payload is required.

Auth Requirement

Requires an authentication key that has ingestion permissions.

Request Examples

Add Synonyms

The format is synonym:original-term The payload is expected to be an array of these. You can define one to one, one to many, or many to many, e.g., synonym,synonym:original-term,original-term,original-term. You should not have spaces between the commas or the space will be included as part of the term.

Example:

Terminal window
curl -X POST -H "Content-Type: application/json" -H "Authorization: read-key-value" --data '["ny:new york,nyc", "lotr:lord of the rings", "iphone,android,phone:android,phone,iphone"]' https://searchcraft-cluster-url/index/:index/synonyms

If you create many to many just note that they will be seperated when you retrieve them via a GET request. When requesting GET /index/:index/synonyms The above example would return:

{
"status": 200,
"data": {
"phone": [
"android",
"iphone"
],
"android": [
"phone",
"iphone"
],
"lotr": [
"lord of the rings"
],
"nyc": [
"new york",
"nyc"
],
"ny": [
"new york",
"nyc"
],
"iphone": [
"phone",
"android"
]
}
}

Delete Synonyms

DELETE /index/:index/synonyms delete one to several synonyms sent in an array of strings.

Terminal window
curl -X DELETE -H "Content-Type: application/json" -H "Authorization: read-key-value" --data '["ny", "lotr"]' https://searchcraft-cluster-url/index/:index/synonyms

Important Note on Synonyms

Synonyms by design ONLY work with fuzzy queries. Exact match queries ignore synonyms.