keyword-analyzer.asciidoc 2.0 KB

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