normalizers.asciidoc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. [[analysis-normalizers]]
  2. == Normalizers
  3. beta[]
  4. Normalizers are similar to analyzers except that they may only emit a single
  5. token. As a consequence, they do not have a tokenizer and only accept a subset
  6. of the available char filters and token filters. Only the filters that work on
  7. a per-character basis are allowed. For instance a lowercasing filter would be
  8. allowed, but not a stemming filter, which needs to look at the keyword as a
  9. whole.
  10. [float]
  11. === Custom normalizers
  12. Elasticsearch does not ship with built-in normalizers so far, so the only way
  13. to get one is by building a custom one. Custom normalizers take a list of char
  14. <<analysis-charfilters, character filters>> and a list of
  15. <<analysis-tokenfilters,token filters>>.
  16. [source,js]
  17. --------------------------------
  18. PUT index
  19. {
  20. "settings": {
  21. "analysis": {
  22. "char_filter": {
  23. "quote": {
  24. "type": "mapping",
  25. "mappings": [
  26. "« => \"",
  27. "» => \""
  28. ]
  29. }
  30. },
  31. "normalizer": {
  32. "my_normalizer": {
  33. "type": "custom",
  34. "char_filter": ["quote"],
  35. "filter": ["lowercase", "asciifolding"]
  36. }
  37. }
  38. }
  39. },
  40. "mappings": {
  41. "type": {
  42. "properties": {
  43. "foo": {
  44. "type": "keyword",
  45. "normalizer": "my_normalizer"
  46. }
  47. }
  48. }
  49. }
  50. }
  51. --------------------------------
  52. // CONSOLE