keyword-analyzer.asciidoc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. [[analysis-keyword-analyzer]]
  2. === Keyword analyzer
  3. ++++
  4. <titleabbrev>Keyword</titleabbrev>
  5. ++++
  6. The `keyword` analyzer is a ``noop'' analyzer which returns the entire input
  7. string as a single token.
  8. [float]
  9. === Example output
  10. [source,console]
  11. ---------------------------
  12. POST _analyze
  13. {
  14. "analyzer": "keyword",
  15. "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
  16. }
  17. ---------------------------
  18. /////////////////////
  19. [source,console-result]
  20. ----------------------------
  21. {
  22. "tokens": [
  23. {
  24. "token": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone.",
  25. "start_offset": 0,
  26. "end_offset": 56,
  27. "type": "word",
  28. "position": 0
  29. }
  30. ]
  31. }
  32. ----------------------------
  33. /////////////////////
  34. The above sentence would produce the following single term:
  35. [source,text]
  36. ---------------------------
  37. [ The 2 QUICK Brown-Foxes jumped over the lazy dog's bone. ]
  38. ---------------------------
  39. [float]
  40. === Configuration
  41. The `keyword` analyzer is not configurable.
  42. [float]
  43. === Definition
  44. The `keyword` analyzer consists of:
  45. Tokenizer::
  46. * <<analysis-keyword-tokenizer,Keyword Tokenizer>>
  47. If you need to customize the `keyword` analyzer then you need to
  48. recreate it as a `custom` analyzer and modify it, usually by adding
  49. token filters. Usually, you should prefer the
  50. <<keyword, Keyword type>> when you want strings that are not split
  51. into tokens, but just in case you need it, this would recreate the
  52. built-in `keyword` analyzer and you can use it as a starting point
  53. for further customization:
  54. [source,console]
  55. ----------------------------------------------------
  56. PUT /keyword_example
  57. {
  58. "settings": {
  59. "analysis": {
  60. "analyzer": {
  61. "rebuilt_keyword": {
  62. "tokenizer": "keyword",
  63. "filter": [ <1>
  64. ]
  65. }
  66. }
  67. }
  68. }
  69. }
  70. ----------------------------------------------------
  71. // TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: keyword_example, first: keyword, second: rebuilt_keyword}\nendyaml\n/]
  72. <1> You'd add any token filters here.