You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
, searchingis_active: true
should give active entities sorted bycreated_at
property.But, searching by
title: ~*paris
should sort by how well the entity matches the queryparis
(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 beentitle: ~*paris; @_score: ASC; @created_at: DESC
, then it works as expected.Related to #263. Somewhat related to #258.
The text was updated successfully, but these errors were encountered: