Skip to content
  • Dylan Griffith's avatar
    Fix Elasticsearch sorting incorrectly from DB · 8a8784f1
    Dylan Griffith authored
    Before this our search results were getting mixed up within a page. The
    [`Records#records`](
    https://github.com/elastic/elasticsearch-rails/blob/v6.1.0/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb#L21
    )
    method is meant to sort again the query results based on the original
    Elasticsearch ordering after loading from the DB, but this was not
    working correctly in our code due to us monkey patching the
    elasticsearch-model Gem and changing the value of
    [`_id`](
    https://gitlab.com/gitlab-org/gitlab/blob/8214da07/ee/lib/gem_extensions/elasticsearch/model/response/records.rb#L9
    )
    for Elasticsearch records.
    
    As such we needed to dig ourselves further into the monkey patch hole.
    This MR replaces a single line inside `Records#records` method, which,
    unfortunately, required us to replace the entire lengthy method.
    
    https://gitlab.com/gitlab-org/gitlab/-/issues/229982
    8a8784f1