Skip to content

Always sort Elasticsearch searches by relevance not updated_at

Dylan Griffith requested to merge 228575-sort-by-relevance-not-updated-at into master

What does this MR do?

TL;DR Elasticsearch defaults to sorting by _score and this is what we want so remove all the explicit sorting.

More information

At present some searches are being sorted by _score (ie. the relevance score) while others are being first sorted by updated_at then _score.

There doesn't really appear to be any good reason to use updated_at as the primary sort followed by _score since this will bury the most relevant matches behind lots of recent matches. Using sort in this way will only ever sort by _score if the updated_at was equal but this is basically never going to happen since these are timestamps so _score in practice is never factoring in to the sorting which probably was never the intent here.

Since the default sorting is by score we can leave it out of all queries.

We can in future look into whether or not we want recency to factor into the sorting using more advanced tools like function_score but for now sorting just by relevance is better than sorting just by updated_at.

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

#228575 (closed)

Edited by Dylan Griffith

Merge request reports