I use the Lucene java QueryParser
with KeywordAnalyzer
. A query like topic:(hello world)
is broken up in to multiple parts by the KeywordTokenizer
so the resulting Query object looks like this topic:(hello) topic:(world)
i.e. Instead of one, I now have two key-value pairs. I would like the QueryParser
to interpret hello world
as one value, without using double quotes. What is the best way to do so?
Parsing topic:("hello world")
results in a single key value combination but, using double quotes is not an option.
I am not using the Lucene search engine. I am using Lucene's QueryParser just for parsing the query, not for searching. The text Hello World
is entered at runtime, by the user so that can change. I would like KeywordTokenizer
to treat Hello World
as one Token instead of parsing splitting it in to two Tokens.