Skip to content

[Elasticsearch] if in pattern matcher mode, treat default sort like it's _score: DESC #264

@dkarlovi

Description

@dkarlovi

Description

Elasticsearch does sorting by creating an implicit property called _score. It allows documents to "contribute to the score" and then the quality of the results is determined by sorting by _score DESC.

This means default sort values should be appended to that sort if we're doing a fuzzy search since the quality of the document's match is directly reflected in its score, sorting by anything else decreases the quality.

Example

If we have default sort @created_at: DESC, searching is_active: true should give active entities sorted by created_at property.

But, searching by title: ~*paris should sort by how well the entity matches the query paris (which means we don't want the newest entity to be first, we want the best match to be first). If the final query would have been title: ~*paris; @_score: ASC; @created_at: DESC, then it works as expected.

Related to #263. Somewhat related to #258.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions