keyword-analyzer.asciidoc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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,js]
  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. // CONSOLE
  16. /////////////////////
  17. [source,js]
  18. ----------------------------
  19. {
  20. "tokens": [
  21. {
  22. "token": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone.",
  23. "start_offset": 0,
  24. "end_offset": 56,
  25. "type": "word",
  26. "position": 0
  27. }
  28. ]
  29. }
  30. ----------------------------
  31. // TESTRESPONSE
  32. /////////////////////
  33. The above sentence would produce the following single term:
  34. [source,text]
  35. ---------------------------
  36. [ The 2 QUICK Brown-Foxes jumped over the lazy dog's bone. ]
  37. ---------------------------
  38. [float]
  39. === Configuration
  40. The `keyword` analyzer is not configurable.
  41. [float]
  42. === Definition
  43. The `keyword` analyzer consists of:
  44. Tokenizer::
  45. * <<analysis-keyword-tokenizer,Keyword Tokenizer>>
  46. If you need to customize the `keyword` analyzer then you need to
  47. recreate it as a `custom` analyzer and modify it, usually by adding
  48. token filters. Usually, you should prefer the
  49. <<keyword, Keyword type>> when you want strings that are not split
  50. into tokens, but just in case you need it, this would recreate the
  51. built-in `keyword` analyzer and you can use it as a starting point
  52. for further customization:
  53. [source,js]
  54. ----------------------------------------------------
  55. PUT /keyword_example
  56. {
  57. "settings": {
  58. "analysis": {
  59. "analyzer": {
  60. "rebuilt_keyword": {
  61. "tokenizer": "keyword",
  62. "filter": [ <1>
  63. ]
  64. }
  65. }
  66. }
  67. }
  68. }
  69. ----------------------------------------------------
  70. // CONSOLE
  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.