whitespace-tokenizer.asciidoc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. [[analysis-whitespace-tokenizer]]
  2. === Whitespace Tokenizer
  3. The `whitespace` tokenizer breaks text into terms whenever it encounters a
  4. whitespace character.
  5. [float]
  6. === Example output
  7. [source,console]
  8. ---------------------------
  9. POST _analyze
  10. {
  11. "tokenizer": "whitespace",
  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",
  22. "start_offset": 0,
  23. "end_offset": 3,
  24. "type": "word",
  25. "position": 0
  26. },
  27. {
  28. "token": "2",
  29. "start_offset": 4,
  30. "end_offset": 5,
  31. "type": "word",
  32. "position": 1
  33. },
  34. {
  35. "token": "QUICK",
  36. "start_offset": 6,
  37. "end_offset": 11,
  38. "type": "word",
  39. "position": 2
  40. },
  41. {
  42. "token": "Brown-Foxes",
  43. "start_offset": 12,
  44. "end_offset": 23,
  45. "type": "word",
  46. "position": 3
  47. },
  48. {
  49. "token": "jumped",
  50. "start_offset": 24,
  51. "end_offset": 30,
  52. "type": "word",
  53. "position": 4
  54. },
  55. {
  56. "token": "over",
  57. "start_offset": 31,
  58. "end_offset": 35,
  59. "type": "word",
  60. "position": 5
  61. },
  62. {
  63. "token": "the",
  64. "start_offset": 36,
  65. "end_offset": 39,
  66. "type": "word",
  67. "position": 6
  68. },
  69. {
  70. "token": "lazy",
  71. "start_offset": 40,
  72. "end_offset": 44,
  73. "type": "word",
  74. "position": 7
  75. },
  76. {
  77. "token": "dog's",
  78. "start_offset": 45,
  79. "end_offset": 50,
  80. "type": "word",
  81. "position": 8
  82. },
  83. {
  84. "token": "bone.",
  85. "start_offset": 51,
  86. "end_offset": 56,
  87. "type": "word",
  88. "position": 9
  89. }
  90. ]
  91. }
  92. ----------------------------
  93. /////////////////////
  94. The above sentence would produce the following terms:
  95. [source,text]
  96. ---------------------------
  97. [ The, 2, QUICK, Brown-Foxes, jumped, over, the, lazy, dog's, bone. ]
  98. ---------------------------
  99. [float]
  100. === Configuration
  101. The `whitespace` tokenizer accepts the following parameters:
  102. [horizontal]
  103. `max_token_length`::
  104. The maximum token length. If a token is seen that exceeds this length then
  105. it is split at `max_token_length` intervals. Defaults to `255`.