Skip to content

Avoid loading Elasticsearch search result objects from the database

In https://gitlab.com/gitlab-org/gitlab-ee/issues/9927 we found multiple elasticsearch optimizations that could be done, but a big one that we still need to tackle is getting rid of all calls to Elasticsearch::Model::Response#records whenever possible.

as per elasticsearch-rails docs

The records method returns the real instances of your model, which is useful when you want to access your model methods -- at the expense of slowing down your application, of course. In most cases, working with results coming from Elasticsearch is sufficient, and much faster

We should get rid of all calls to this method and see about using the information coming back from Elasticsearch to instantiate objects instead.

The calls in question occur in Gitlab::Elastic::SearchResults

cc/ @stanhu