HomeDev GuideRecipesAPI ReferenceGraphQL
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In
GitHubNuGetDev CommunityDoc feedback


You can use synonyms to improve search results by adding uni- or bi-directional relationships between phrases.

Note

To learn how to add synonyms through the administrative interface, see [Adding synonyms for similar phrases](🔗).

## Use synonyms

To enable search results to use synonyms, use the `UsingSynonyms` extension method for `IQueriedSearch` in `EPiServer.Find` namespace:



## Manage synonyms

A synonym has an ID to use on update and removal. The ID is defined by

  • the **phrase** _(a)_

  • the **synonymous phrase** _(b)_

  • whether relationship is **bidirectional**; meaning searches for _b_ also return results for _a_

  • **tags** for categorizing synonyms, for example, based on sites and languages

### Client extension

The synonyms client is made available through the extension method `Synonyms` on the Optimizely Search & Navigation client.



### Add method



In this example, **bike** is the phrase, **bicycle** is the synonym, and **true** indicates that the relationship is bidirectional.

### Get method

To get a synonym, pass its id to the `Get` method of the `Synonyms` client.



### Delete method

To delete a synonym, pass its id to the `Delete` method of the `Synonyms` client.



### List method

To retrieve synonyms, use the `List` method, which has size and from arguments to allow paging.



Size indicates the number of synonyms to return per page. From indicates the synonym at which to start the list.

The default size value is 10, and the default from value is 0. If you run client.Synonyms().List() with no parameters, it returns the first 10 synonyms.

**Examples**

  • `client.Synonyms().List(5)` returns the first 5 synonyms.

  • `client.Synonyms().List(5, 5)` returns the second page of the synonym list, 5 synonyms starting with sixth result (it skips the first 5).

  • `client.Synonyms().List(5, 10)` returns the third page of the synonym list: 5 synonyms starting from the eleventh result (it skips the first 10).

### CommandActions argument

The `Add`, `Get`, `Delete`, and `List` methods have overloads for passing a `commandAction`, which is run with the due command as an argument just before command execution.