2013-08-28 19:24:34 -04:00
|
|
|
[[mapping-analyzer-field]]
|
|
|
|
=== `_analyzer`
|
|
|
|
|
|
|
|
The `_analyzer` mapping allows to use a document field property as the
|
|
|
|
name of the analyzer that will be used to index the document. The
|
|
|
|
analyzer will be used for any field that does not explicitly defines an
|
|
|
|
`analyzer` or `index_analyzer` when indexing.
|
|
|
|
|
|
|
|
Here is a simple mapping:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"type1" : {
|
|
|
|
"_analyzer" : {
|
|
|
|
"path" : "my_field"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
The above will use the value of the `my_field` to lookup an analyzer
|
2014-03-07 08:21:45 -05:00
|
|
|
registered under it. For example, indexing the following doc:
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"my_field" : "whitespace"
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
Will cause the `whitespace` analyzer to be used as the index analyzer
|
|
|
|
for all fields without explicit analyzer setting.
|
|
|
|
|
|
|
|
The default path value is `_analyzer`, so the analyzer can be driven for
|
2014-03-07 08:21:45 -05:00
|
|
|
a specific document by setting the `_analyzer` field in it. If a custom json
|
2013-08-28 19:24:34 -04:00
|
|
|
field name is needed, an explicit mapping with a different path should
|
|
|
|
be set.
|
|
|
|
|
|
|
|
By default, the `_analyzer` field is indexed, it can be disabled by
|
|
|
|
settings `index` to `no` in the mapping.
|