pattern-tokenizer.asciidoc 1.1 KB

1234567891011121314151617181920212223242526272829
  1. [[analysis-pattern-tokenizer]]
  2. === Pattern Tokenizer
  3. A tokenizer of type `pattern` that can flexibly separate text into terms
  4. via a regular expression. Accepts the following settings:
  5. [cols="<,<",options="header",]
  6. |======================================================================
  7. |Setting |Description
  8. |`pattern` |The regular expression pattern, defaults to `\\W+`.
  9. |`flags` |The regular expression flags.
  10. |`group` |Which group to extract into tokens. Defaults to `-1` (split).
  11. |======================================================================
  12. *IMPORTANT*: The regular expression should match the *token separators*,
  13. not the tokens themselves.
  14. `group` set to `-1` (the default) is equivalent to "split". Using group
  15. >= 0 selects the matching group as the token. For example, if you have:
  16. ------------------------
  17. pattern = \\'([^\']+)\\'
  18. group = 0
  19. input = aaa 'bbb' 'ccc'
  20. ------------------------
  21. the output will be two tokens: 'bbb' and 'ccc' (including the ' marks).
  22. With the same input but using group=1, the output would be: bbb and ccc
  23. (no ' marks).