Always sort Elasticsearch searches by relevance not updated_at
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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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