Mahesh Chand
Mahesh Chand

Reputation: 3250

How can i stop elastic search to not tokenize words having hypen between them?

Elastic search tokenizes the word if they have - between two or more words. For example, probably-not. It will tokenize it into two words. For more info refer But I don't want it. I know I can achieve the same thing using underscore instead of the hyphen.

Upvotes: 2

Views: 337

Answers (1)

Adam T
Adam T

Reputation: 1691

Use a whitespace tokenizer. For example:

POST _analyze
{
  "tokenizer": "whitespace",
  "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}

This will produce the following terms:

[ The, 2, QUICK, Brown-Foxes, jumped, over, the, lazy, dog's, bone. ]

https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-whitespace-tokenizer.html

Upvotes: 2

Related Questions