Skip to content

Commit 62dc650

Browse files
committed
Update Synonyms page, mention UI option
1 parent b69b60b commit 62dc650

File tree

1 file changed

+61
-30
lines changed

1 file changed

+61
-30
lines changed

solutions/search/full-text/search-with-synonyms.md

Lines changed: 61 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ products:
88
- id: elasticsearch
99
---
1010

11-
# Search with synonyms
11+
# Search with synonyms [search-with-synonyms]
1212

1313
$$$ece-add-custom-bundle-example-synonyms$$$
1414
::::{note}
1515
Learn about [adding custom synonym bundles](/solutions/search/full-text/search-with-synonyms.md#ece-add-custom-bundle-example-synonyms) to your {{ece}} deployment.
1616
::::
1717

18-
1918
% TODO: these bundle links do not belong here
2019

2120
$$$ece-add-custom-bundle-example-LDA$$$
@@ -26,8 +25,6 @@ $$$ece-add-custom-bundle-example-cacerts$$$
2625

2726
$$$ece-add-custom-bundle-example-LDAP$$$
2827

29-
# Search with synonyms [search-with-synonyms]
30-
3128
Synonyms are words or phrases that have the same or similar meaning. They are an important aspect of search, as they can improve the search experience and increase the scope of search results.
3229

3330
Synonyms allow you to:
@@ -38,29 +35,75 @@ Synonyms allow you to:
3835

3936
Synonyms are grouped together using **synonyms sets**. You can have as many synonyms sets as you need.
4037

41-
In order to use synonyms sets in {{es}}, you need to:
38+
## How synonyms work in Elasticsearch
39+
40+
To use synonyms in {{es}}, you need to follow this workflow:
41+
42+
1. **Create synonym sets and rules** - Define which terms are equivalent and where to store your synonym sets
43+
2. **Configure analyzers** - Apply synonyms during text analysis
44+
3. **Test and apply** - Verify your configuration works correctly
45+
46+
## Step 1: Create synonym sets and rules
47+
48+
You can create synonym sets and rules using several methods:
49+
50+
### Synonym rule formats
4251

43-
* [Store your synonyms set](#synonyms-store-synonyms)
44-
* [Configure synonyms token filters and analyzers](#synonyms-synonym-token-filters)
52+
Before creating synonym sets, you need to understand how to write synonym rules. Synonym rules define which terms should be treated as equivalent during search and indexing.
4553

54+
There are two main formats for synonym rules:
4655

47-
## Store your synonyms set [synonyms-store-synonyms]
56+
**Explicit mappings** use `=>` to specify exact replacements:
57+
```
58+
i-pod, i pod => ipod
59+
sea biscuit, sea biscit => seabiscuit
60+
```
4861

49-
Your synonyms sets need to be stored in {{es}} so your analyzers can refer to them. There are three ways to store your synonyms sets:
62+
**Equivalent synonyms** use commas to group interchangeable terms:
63+
```
64+
ipod, i-pod, i pod
65+
foozball, foosball
66+
universe, cosmos
67+
lol, laughing out loud
68+
```
5069

70+
The behavior of equivalent synonyms depends on the `expand` parameter in your token filter configuration:
71+
- If `expand=true`: `ipod, i-pod, i pod` expands to `ipod, i-pod, i pod`
72+
- If `expand=false`: `ipod, i-pod, i pod` maps to just `ipod`
5173

52-
### Synonyms API [synonyms-store-synonyms-api]
74+
### Method 1: Kibana UI
75+
76+
```yaml {applies_to}
77+
serverless:
78+
elasticsearch:
79+
```
80+
81+
You can create and manage synonym sets and synonym rules using the Kibana user interface. This provides a user-friendly way to manage synonyms without using APIs or file uploads.
82+
83+
To create a synonym set using the UI:
84+
85+
1. Navigate to **Elasticsearch** > **Synonyms** or use the [global search field](docs-content://explore-analyze/query-filter/filtering.md#_finding_your_apps_and_objects)
86+
2. Click **Get started**
87+
3. Enter a name for your synonym set
88+
4. Add your synonym rules in the editor using the formats above:
89+
- Explicit mappings: `i-pod, i pod => ipod`
90+
- Equivalent synonyms: `ipod, i-pod, i pod`
91+
5. Click **Create** to save your synonym set
92+
93+
The UI supports the same synonym rule formats as the file-based approach. Changes made through the UI will automatically reload the associated analyzers.
94+
95+
### Method 2: REST API
5396

5497
You can use the [synonyms APIs](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-synonyms) to manage synonyms sets. This is the most flexible approach, as it allows to dynamically define and modify synonyms sets. For examples of how to
5598
create or update a synonym set with APIs, refer to the [Create or update synonyms set API examples](/solutions/search/full-text/search-with-synonyms.md) page.
5699

57100
Changes in your synonyms sets will automatically reload the associated analyzers.
58101

59-
### Synonyms File [synonyms-store-synonyms-file]
102+
### Method 3: File-based
60103

61104
You can store your synonyms set in a file.
62105

63-
A synonyms set file needs to be uploaded to all your cluster nodes, and be located in the configuration directory for your {{es}} distribution. If youre using {{ech}}, you can upload synonyms files using [custom bundles](../../../deploy-manage/deploy/elastic-cloud/upload-custom-plugins-bundles.md).
106+
A synonyms set file needs to be uploaded to all your cluster nodes, and be located in the configuration directory for your {{es}} distribution. If you're using {{ech}}, you can upload synonyms files using [custom bundles](../../../deploy-manage/deploy/elastic-cloud/upload-custom-plugins-bundles.md).
64107

65108
An example synonyms file:
66109

@@ -104,28 +147,22 @@ When a synonyms set is updated, search analyzers that use it need to be refreshe
104147

105148
This manual syncing and reloading makes this approach less flexible than using the [synonyms API](../../../solutions/search/full-text/search-with-synonyms.md#synonyms-store-synonyms-api).
106149

107-
108-
### Inline [synonyms-store-synonyms-inline]
150+
### Method 4: Inline
109151

110152
You can test your synonyms by adding them directly inline in your token filter definition.
111153

112154
::::{warning}
113155
Inline synonyms are not recommended for production usage. A large number of inline synonyms increases cluster size unnecessarily and can lead to performance issues.
114-
115156
::::
116157

117-
118-
119-
### Configure synonyms token filters and analyzers [synonyms-synonym-token-filters]
158+
## Step 2: Configure synonyms token filters and analyzers [synonyms-synonym-token-filters]
120159

121160
Once your synonyms sets are created, you can start configuring your token filters and analyzers to use them.
122161

123162
::::{warning}
124163
Synonyms sets must exist before they can be added to indices. If an index is created referencing a nonexistent synonyms set, the index will remain in a partially created and inoperable state. The only way to recover from this scenario is to ensure the synonyms set exists then either delete and re-create the index, or close and re-open the index.
125-
126164
::::
127165

128-
129166
::::{warning}
130167
Invalid synonym rules can cause errors when applying analyzer changes. For reloadable analyzers, this prevents reloading and applying changes. You must correct errors in the synonym rules and reload the analyzer.
131168

@@ -134,19 +171,16 @@ An index with invalid synonym rules cannot be reopened, making it inoperable whe
134171
* A node containing the index starts
135172
* The index is opened from a closed state
136173
* A node restart occurs (which reopens the node assigned shards)
137-
138174
::::
139175

140-
141176
{{es}} uses synonyms as part of the [analysis process](../../../manage-data/data-store/text-analysis.md). You can use two types of [token filter](elasticsearch://reference/text-analysis/token-filter-reference.md) to include synonyms:
142177

143178
* [Synonym graph](elasticsearch://reference/text-analysis/analysis-synonym-graph-tokenfilter.md): It is recommended to use it, as it can correctly handle multi-word synonyms ("hurriedly", "in a hurry").
144179
* [Synonym](elasticsearch://reference/text-analysis/analysis-synonym-tokenfilter.md): Not recommended if you need to use multi-word synonyms.
145180

146181
Check each synonym token filter documentation for configuration details and instructions on adding it to an analyzer.
147182

148-
149-
### Test your analyzer [synonyms-test-analyzer]
183+
## Step 3: Test your analyzer [synonyms-test-analyzer]
150184

151185
You can test an analyzer configuration without modifying your index settings. Use the [analyze API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-analyze) to test your analyzer chain:
152186

@@ -165,17 +199,14 @@ GET /_analyze
165199
}
166200
```
167201

168-
169-
### Apply synonyms at index or search time [synonyms-apply-synonyms]
202+
## Step 4: Apply synonyms at index or search time [synonyms-apply-synonyms]
170203

171204
Analyzers can be applied at [index time or search time](../../../manage-data/data-store/text-analysis/index-search-analysis.md).
172205

173206
You need to decide when to apply your synonyms:
174207

175-
* Index time: Synonyms are applied when the documents are indexed into {{es}}. This is a less flexible alternative, as changes to your synonyms require [reindexing](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-reindex).
176-
* Search time: Synonyms are applied when a search is executed. This is a more flexible approach, which doesn’t require reindexing. If token filters are configured with `"updateable": true`, search analyzers can be [reloaded](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-reload-search-analyzers) when you make changes to your synonyms.
177-
178-
Synonyms sets created using the [synonyms API](../../../solutions/search/full-text/search-with-synonyms.md#synonyms-store-synonyms-api) can only be used at search time.
208+
* **Index time**: Synonyms are applied when the documents are indexed into {{es}}. This is a less flexible alternative, as changes to your synonyms require [reindexing](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-reindex).
209+
* **Search time**: Synonyms are applied when a search is executed. This is a more flexible approach, which doesn't require reindexing. If token filters are configured with `"updateable": true`, search analyzers can be [reloaded](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-reload-search-analyzers) when you make changes to your synonyms.
179210

180211
You can specify the analyzer that contains your synonyms set as a [search time analyzer](../../../manage-data/data-store/text-analysis/specify-an-analyzer.md#specify-search-analyzer) or as an [index time analyzer](../../../manage-data/data-store/text-analysis/specify-an-analyzer.md#specify-index-time-analyzer).
181212

0 commit comments

Comments
 (0)