analyzer-field.asciidoc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. [[mapping-analyzer-field]]
  2. === `_analyzer`
  3. The `_analyzer` mapping allows to use a document field property as the
  4. name of the analyzer that will be used to index the document. The
  5. analyzer will be used for any field that does not explicitly defines an
  6. `analyzer` or `index_analyzer` when indexing.
  7. Here is a simple mapping:
  8. [source,js]
  9. --------------------------------------------------
  10. {
  11. "type1" : {
  12. "_analyzer" : {
  13. "path" : "my_field"
  14. }
  15. }
  16. }
  17. --------------------------------------------------
  18. The above will use the value of the `my_field` to lookup an analyzer
  19. registered under it. For example, indexing a the following doc:
  20. [source,js]
  21. --------------------------------------------------
  22. {
  23. "my_field" : "whitespace"
  24. }
  25. --------------------------------------------------
  26. Will cause the `whitespace` analyzer to be used as the index analyzer
  27. for all fields without explicit analyzer setting.
  28. The default path value is `_analyzer`, so the analyzer can be driven for
  29. a specific document by setting `_analyzer` field in it. If custom json
  30. field name is needed, an explicit mapping with a different path should
  31. be set.
  32. By default, the `_analyzer` field is indexed, it can be disabled by
  33. settings `index` to `no` in the mapping.