Suppose that i have 5 documents having the field text as follow:
- the red house is beautiful
- the house is little
- the red fish
- the red and yellow house is big
What kind of query should i use to retrieve the documents such that the rank is the following if i search for "red house":
- the red house is beautiful and big [matching: red house]
- the red and yellow house is big [matching: red x x house]
- the house is little [matching: house]
- the red fish [matching: red]
What i need is to give an high rank to the documents that match the phrase i've searched, and a lower score to the documents that have just a part of the phrase searched. Notice that the string query could contains also more than 2 terms.
It is like a PhraseQuery in which each term can appear or not, and in which the closer are the terms the higher is the score.
I've tried to use compose a PhraseQuery with a TermQuery but the result is not what i need.
How can i do?
Thanks