Search service incorrectly uses elasticsearch when indexing, but not search, is enabled
Originally spotted in gitlab-com/gl-infra/infrastructure#6587 (closed)
::Project has a
use_elasticsearch? method that is designed to tell us whether we should index the project or not. However, the project search service uses it unconditionally to decide whether to search using elasticsearch or not:
# Project def use_elasticsearch? ::Gitlab::CurrentSettings.elasticsearch_indexes_project?(self) end # ApplicationSetting def elasticsearch_indexes_project?(project) return false unless elasticsearch_indexing? return true unless elasticsearch_limit_indexing? elasticsearch_limited_projects.exists?(project.id) end # Search::ProjectService def use_elasticsearch? project.use_elasticsearch? end
The same problem exists in group, but not global, search.