Skip to content

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

@elasticmachine

Description

@elasticmachine

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)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions