Skip to content

ES web indexing doesn't index personal snippets

Summary

We provide a button in the GitLab administration to index all current data into Elasticsearch. This currently only indexes projects and their associated data, but not personal snippets which aren't associated to a project and need to be indexed through a Rake task.

The web indexing button is enabled in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/15390/diffs, and documented (along with the requirement for the Rake task) in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31972

Steps to reproduce

  1. Disable ES indexing
  2. Create a personal snippet
  3. Enable ES indexing
  4. Click Start Indexing in the administration

What is the current bug behavior?

Personal snippets are not indexed.

What is the expected correct behavior?

Personal snippets are indexed.

Output of checks

This bug happens on GitLab.com

Possible fixes

Admin::ElasticsearchController#enqueue_index currently queues an Elastic::IndexProjectsService, which doesn't catch personal snippets (but does catch project snippets).

We don't have a worker yet to index personal snippets specifically, but could add one which indexes them through e.g. Elastic::IndexRecordService.

This worker could then also be used in the Rake task gitlab:elastic:index_snippets which currently just runs Snippet.es_import synchronously, though as long as https://gitlab.com/gitlab-org/gitlab-ee/issues/12168 remains unfixed we still need to index both project and personal snippets in the Rake task.