Synonyms
To make the search more robust and relevant, synonyms are introduced. Synonyms are also a unique feature of NoChannel Search. As the name implies, the purpose of synonyms is to search for words with similar meanings and also retrieve them in the results. Because of the synonyms, all ambiguities while searching are removed for the searcher.
For example, in some European countries, cars are commonly known as autos or automobiles. If a person searches for the word "auto", the search result will retrieve all "car" items in the result.
To add a synonym in an index, it is important to reindex the data otherwise the synonyms will not be updated.
There are three different types of Synonyms:
- Alias: Grouping multiple keywords together that have similar meanings to them. For example, "table", "desk", and "counter". If users search for "desk" then "table" and "counter" will be searched too.
- Contraction: Grouping together a list of keywords in such a way that if any word is searched for in the group, the results retrieved correspond to one of the words in the group only.
For example, if the contraction is set to "table" in a group of "table", "desk", and "counter", even if the user searches for the word "desk" the search will retrieve all the results of table items only.
- Expansion: It is a one-to-many relation between the keywords i.e. one keyword maps to multiple keywords. On searching that one keyword, all the other mapped keywords are searched for. For example, mapping the word "table" on "desk" and "counter" will search for desk and counter every time table is searched.
To better understand the concept of synonyms, let us look at the following example for each type of synonym for the word "chair".
The API call to create Alias synonyms is:
POST https://api.upstartcommerce.com/v1/search/synonyms/
The following code block represents the creation of alias synonyms for a word. In this case, it is "chair". Catalog in the API refers to the name of an existing query pipeline.
Notice that an array called synonyms is defined which has all three words; “table”, "desk", and "counter" in it. The type field explicitly defines the type of Synonym as Alias.
Searching for a table yields results for counters and desks as well.
The API call to create expansion synonyms is:
POST *https://api.upstartcommerce.com/v1/search/synonyms
The following code block represents the creation of expansion synonyms for a word. In this case, it is a "table". Catalog in the API refers to the name of an existing query pipeline.
The type field explicitly defines the type of Synonym as Expansion. The field "from" in the synonym block defines the word expansion as "table". The field defines the words "Desk" and "Counter" that will be contracted with "table".
Searching for "table" will yield results for "counter" and "desk".
The API call to create contraction synonyms is:
POST https://api.upstartcommerce.com/v1search/synonyms/
The following code block represents the creation of contractions synonyms for a word. In this case, it is a "table". Catalog in the API refers to the name of an existing query pipeline.
The type field explicitly defines the type of synonym as Contraction. The field to in the synonym block defines the word of contraction "table". The field defines the words "Desk" and "Counter" that will be contracted with "table".
Searching for "table", "desk", or "counter" will yield results only for "table".
Similar to the Create API, CRUD operations can be performed to update, delete, and manage the synonyms directory.