Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: score is not calculated for a match statement when combined with filter-like statements #29685

Closed
elasticmachine opened this issue Apr 24, 2018 · 0 comments
Labels

Comments

@elasticmachine
Copy link
Collaborator

Original comment by @astefan:

A query like SELECT SCORE(), * FROM library WHERE match(author,'dan') does calculate and output the score of the results, while something like SELECT SCORE(), * FROM library WHERE match(author,'dan') AND (page_count IS NULL OR page_count > 200) doesn't.

The reason seems to be the query in the first case it's simply creating a match while the second one is wrongly wrapping the same match query in a bools filter (which is not calculating the score by default). While ok to wrap it in a bool, but maybe not inside a filter. I think the same outcome can be obtained by using must statements instead of filter ones only when the scoring is needed (the presence of SCORE() anywhere in the query)?

costin added a commit that referenced this issue May 21, 2018
Make all bool constructs use match/should (that is a query context) as
that is controlled and changed to a filter context by ES automatically
based on the sort order (_doc, field vs _sort) and trackScores.

Fix #29685
costin added a commit that referenced this issue May 21, 2018
Make all bool constructs use match/should (that is a query context) as
that is controlled and changed to a filter context by ES automatically
based on the sort order (_doc, field vs _sort) and trackScores.

Fix #29685
costin added a commit to costin/elasticsearch that referenced this issue Jun 13, 2018
Make all bool constructs use match/should (that is a query context) as
that is controlled and changed to a filter context by ES automatically
based on the sort order (_doc, field vs _sort) and trackScores.

Fix elastic#29685
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant