I’ve got an index where I need to get all documents with a standard search, still ranked by relevance, even if a document isn’t a hit.
My first idea is to add a field that is always matched, but that might deform the relevance score.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use a
BooleanQueryto combine your original query with aMatchAllDocsQuery. You can mitigate the effect this has on scoring by setting the boost on theMatchAllDocsQueryto zero before you combine it with your main query. This way you don’t have to add an otherwise bogus field to the index.For example:
This should give you hits from
standardQueryfollowed by the rest of the documents in the index.