Question

I am writing some code the need to include all the words in the search string, eg "Apple is red". I am currently using MultiFieldQueryParser, but the search query will be (title:"apple ? red" body:"apple ? red"). I want the query looks exactly what the string should be. "apple ? red" should become "apple is red". How to I do that?

Was it helpful?

Solution

Your query looks correct. The question mark in the output indicates a position increment, it doesn't indicate an actual term in the query.

The word "is" is removed from the query and the index by StandardAnalyzer, since it is a stop word in the default stop word set. StopFilter removes those terms, but increments the position to indicate where the term was removed to enable closer matching with phrase queries.

Unless you see an issue with the results of the query, there appears to be nothing wrong with it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top