Search for hyphen words with Lucene

I want lucen to look for words, for example: energy efficiency or "energy efficiency" as one word

So, if the input is energy-saving, the tokenizer generates expressions such as energy efficiency or energy efficiency or energy efficiency

So lucene is returning with pages containing “energy efficiency” and “energy efficiency”, but I want it to come back exclusively with pages for energy-saving

So, the question is how can I change the standard instructions for finding energy efficiency as a whole word, and not break it down into separate words.

+4
source share
1 answer

Use WhitespaceAnalyzer instead of standardAnalyzer .
This will generate tokens, separating only by spaces. But check out other things to be changed.

+7
source

All Articles