Movatterモバイル変換


[0]ホーム

URL:


Loading
  1. Elastic Docs/
  2. Reference/
  3. Elasticsearch/
  4. Mapping/
  5. Mapping parameters

search_analyzer

Usually, the sameanalyzer should be applied at index time and at search time, to ensure that the terms in the query are in the same format as the terms in the inverted index.

Sometimes, though, it can make sense to use a different analyzer at search time, such as when using theedge_ngram tokenizer for autocomplete or when using search-time synonyms.

By default, queries will use theanalyzer defined in the field mapping, but this can be overridden with thesearch_analyzer setting:

PUT my-index-000001{  "settings": {    "analysis": {      "filter": {        "autocomplete_filter": {          "type": "edge_ngram",          "min_gram": 1,          "max_gram": 20        }      },      "analyzer": {        "autocomplete": {          "type": "custom",          "tokenizer": "standard",          "filter": [            "lowercase",            "autocomplete_filter"          ]        }      }    }  },  "mappings": {    "properties": {      "text": {        "type": "text",        "analyzer": "autocomplete",        "search_analyzer": "standard"      }    }  }}PUT my-index-000001/_doc/1{  "text": "Quick Brown Fox"}GET my-index-000001/_search{  "query": {    "match": {      "text": {        "query": "Quick Br",        "operator": "and"      }    }  }}
  1. Analysis settings to define the customautocomplete analyzer.
  2. Thetext field uses theautocomplete analyzer at index time, but thestandard analyzer at search time.
  3. This field is indexed as the terms: [q,qu,qui,quic,quick,b,br,bro,brow,brown,f,fo,fox ]
  4. The query searches for both of these terms: [quick,br ]

SeeIndex time search-as-you- type for a full explanation of this example.

Tip

Thesearch_analyzer setting can be updated on existing fields using theupdate mapping API. Note, that in order to do so, any existing "analyzer" setting and "type" need to be repeated in the updated field definition.


[8]ページ先頭

©2009-2026 Movatter.jp