You're viewing version 2.14 of the OpenSearch documentation. This version is no longer maintained. For the latest version, see the current documentation. For information about OpenSearch version maintenance, see Release Schedule and Maintenance Policy.
Index analyzers
Index analyzers are specified at indexing time and are used to analyze text fields when indexing a document.
Determining which index analyzer to use
To determine which analyzer to use for a field when a document is indexed, OpenSearch examines the following parameters in order:
- The
analyzer
mapping parameter of the field - The
analysis.analyzer.default
index setting - The
standard
analyzer (default)
When specifying an index analyzer, keep in mind that in most cases, specifying an analyzer for each text
field in an index works best. Analyzing both the text field (at indexing time) and the query string (at query time) with the same analyzer ensures that the search uses the same terms as those that are stored in the index.
For information about verifying which analyzer is associated with which field, see Verifying analyzer settings.
Specifying an index analyzer for a field
When creating index mappings, you can supply the analyzer
parameter for each text field. For example, the following request specifies the simple
analyzer for the text_entry
field:
PUT testindex
{
"mappings": {
"properties": {
"text_entry": {
"type": "text",
"analyzer": "simple"
}
}
}
}
Specifying a default index analyzer for an index
If you want to use the same analyzer for all text fields in an index, you can specify it in the analysis.analyzer.default
setting as follows:
PUT testindex
{
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "simple"
}
}
}
}
}
If you don’t specify a default analyzer, the standard
analyzer is used.