simplepatternsplit-tokenizer.asciidoc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. [[analysis-simplepatternsplit-tokenizer]]
  2. === Simple Pattern Split Tokenizer
  3. The `simple_pattern_split` tokenizer uses a regular expression to split the
  4. input into terms at pattern matches. The set of regular expression features it
  5. supports is more limited than the <<analysis-pattern-tokenizer,`pattern`>>
  6. tokenizer, but the tokenization is generally faster.
  7. This tokenizer does not produce terms from the matches themselves. To produce
  8. terms from matches using patterns in the same restricted regular expression
  9. subset, see the <<analysis-simplepattern-tokenizer,`simple_pattern`>>
  10. tokenizer.
  11. This tokenizer uses {lucene-core-javadoc}/org/apache/lucene/util/automaton/RegExp.html[Lucene regular expressions].
  12. For an explanation of the supported features and syntax, see <<regexp-syntax,Regular Expression Syntax>>.
  13. The default pattern is the empty string, which produces one term containing the
  14. full input. This tokenizer should always be configured with a non-default
  15. pattern.
  16. [float]
  17. === Configuration
  18. The `simple_pattern_split` tokenizer accepts the following parameters:
  19. [horizontal]
  20. `pattern`::
  21. A {lucene-core-javadoc}/org/apache/lucene/util/automaton/RegExp.html[Lucene regular expression], defaults to the empty string.
  22. [float]
  23. === Example configuration
  24. This example configures the `simple_pattern_split` tokenizer to split the input
  25. text on underscores.
  26. [source,console]
  27. ----------------------------
  28. PUT my_index
  29. {
  30. "settings": {
  31. "analysis": {
  32. "analyzer": {
  33. "my_analyzer": {
  34. "tokenizer": "my_tokenizer"
  35. }
  36. },
  37. "tokenizer": {
  38. "my_tokenizer": {
  39. "type": "simple_pattern_split",
  40. "pattern": "_"
  41. }
  42. }
  43. }
  44. }
  45. }
  46. POST my_index/_analyze
  47. {
  48. "analyzer": "my_analyzer",
  49. "text": "an_underscored_phrase"
  50. }
  51. ----------------------------
  52. /////////////////////
  53. [source,console-result]
  54. ----------------------------
  55. {
  56. "tokens" : [
  57. {
  58. "token" : "an",
  59. "start_offset" : 0,
  60. "end_offset" : 2,
  61. "type" : "word",
  62. "position" : 0
  63. },
  64. {
  65. "token" : "underscored",
  66. "start_offset" : 3,
  67. "end_offset" : 14,
  68. "type" : "word",
  69. "position" : 1
  70. },
  71. {
  72. "token" : "phrase",
  73. "start_offset" : 15,
  74. "end_offset" : 21,
  75. "type" : "word",
  76. "position" : 2
  77. }
  78. ]
  79. }
  80. ----------------------------
  81. /////////////////////
  82. The above example produces these terms:
  83. [source,text]
  84. ---------------------------
  85. [ an, underscored, phrase ]
  86. ---------------------------