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
Section titled “API Endpoints”GET /index/:index/synonymsReturns the synonyms for an index.POST /index/:index/synonymsAdd synonyms to an index.DELETE /index/:index/synonymsDelete an array of synonyms from an index.DELETE /index/:index/synonyms/allDelete all synonyms from an index.- No payload is required.
Auth Requirement
Section titled “Auth Requirement”Requires an authentication key that has ingestion permissions.
Request Examples
Section titled “Request Examples”Add Synonyms
Section titled “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:
curl -X POST -H "Content-Type: application/json" -H "Authorization: ingest-key-value" --data '["ny:new york,nyc", "lotr:lord of the rings", "iphone,android,phone:android,phone,iphone"]' https://searchcraft-cluster-url/index/:index/synonymsIf 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
Section titled “Delete Synonyms”DELETE /index/:index/synonyms delete one to several synonyms sent in an array of strings.
curl -X DELETE -H "Content-Type: application/json" -H "Authorization: ingest-key-value" --data '["ny", "lotr"]' https://searchcraft-cluster-url/index/:index/synonymsImportant Note on Synonyms
Section titled “Important Note on Synonyms”Synonyms by design ONLY work with fuzzy queries. Exact match queries ignore synonyms.