UAX URL email tokenizer

The uax_url_email tokenizer is like the standard tokenizer except that it recognises URLs and email addresses as single tokens.

Example output

  1. POST _analyze
  2. {
  3. "tokenizer": "uax_url_email",
  4. "text": "Email me at john.smith@global-international.com"
  5. }

The above sentence would produce the following terms:

  1. [ Email, me, at, john.smith@global-international.com ]

while the standard tokenizer would produce:

  1. [ Email, me, at, john.smith, global, international.com ]

Configuration

The uax_url_email tokenizer accepts the following parameters:

max_token_length

The maximum token length. If a token is seen that exceeds this length then it is split at max_token_length intervals. Defaults to 255.

Example configuration

In this example, we configure the uax_url_email tokenizer to have a max_token_length of 5 (for demonstration purposes):

  1. PUT my-index-000001
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "my_analyzer": {
  7. "tokenizer": "my_tokenizer"
  8. }
  9. },
  10. "tokenizer": {
  11. "my_tokenizer": {
  12. "type": "uax_url_email",
  13. "max_token_length": 5
  14. }
  15. }
  16. }
  17. }
  18. }
  19. POST my-index-000001/_analyze
  20. {
  21. "analyzer": "my_analyzer",
  22. "text": "john.smith@global-international.com"
  23. }

The above example produces the following terms:

  1. [ john, smith, globa, l, inter, natio, nal.c, om ]