elastic: snippet search should fully respect elasticsearch selective search
Currently, snippets are always searched using elasticsearch if it's enabled, regardless of the value of "elasticsearch limited namespaces/projects". The idea during implementation was that the total number of snippets was very small, so making it selective wasn't worth the effort. Some background: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/9861#note_151969006 and https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/9861#note_153813219
However, this may not be true in the future, for GitLab.com, or now, for some of our customers. Additionally, having this inconsistency makes the indexing process more complicated, and harder to understand - it's mandatory to run the index_snippets
rake task when using limiting, otherwise you get back incorrect search results.
I think this should be part of an overall effort to merge Search::SnippetService
into the existing Search::{Global,Group,Project}Service
. There's no particular reason to have it implemented as a parallel service.
We can have "personal snippet" and "project snippet" scopes, and make the former available only for global search. The latter becomes available at all levels, and can benefit from the existing elastic vs. database search logic in those services.