Allow all projects to be indexed
Background
Related to #428070 (closed)
This change only affects instances where Elasticsearch limiting is enabled and configured to limit indexing to specific namespaces or projects. Note: This is how Advanced search is setup on GitLab.com
The MR only makes changes to the indexing process but does not touch any code related to search.
This MR is broken into three parts (all behind the feature flag introduced in this MR)
Merge request | What it does |
---|---|
|
Allow all projects being indexed |
!137308 (merged) | Support all projects being indexed when performing deletes and transfers to another namespace |
!138098 (merged) | elastic rake task updates |
What does this MR do and why?
This MR allows all projects to be indexed and includes:
- introduction of
search_index_all_projects
feature flag, gated to the project - a new method to determine if the project's associated data is indexed
- changes to callbacks and the
track!
method to determine if the associated data should be indexed
Screenshots or screen recordings
No UI changes. Only changes are to determine if a project record is indexed for Advanced search.
How to set up and validate locally
- Setup elasticsearch in gdk
- Enable advanced search and Elasticsearch indexing restrictions, I chose one group and project
- Disable the feature flag in rails console:
Feature.disable(:search_index_all_projects)
- Reindex everything from scratch:
bundle exec rake gitlab:elastic:index
- Verify that only the expected projects exist in the index, in my case that is 3 projects (2 under the selected group, and 1 selected project)
curl --request GET \ --url http://localhost:9200/gitlab-development-projects/_search \ --data '{ "query": { "bool": { "must": [ { "term": { "type": { "value": "project" } } } ] } } }'
- enable the feature flag for a project:
Feature.enable(:search_index_all_projects, Project.find(7))
(flightjs project for me) - update the project settings (I updated the description)
- verify in the
log/elasticsearch.log
that ONLY the project record is queued for indexing (not any associated records) - verify that now one more project exists in the index and no associated data exists
curl --request GET \ --url 'http://localhost:9200/gitlab-development-*/_search' \ --header 'Content-Type: application/json' \ --data '{ "query": { "bool": { "must": [ { "term": { "project_id": { "value": 7 } } } ] } } }'
- create a new project
- verify that it is not queued for indexing and does not exist in the index
- enable the feature flag fully:
Feature.enable(:search_index_all_projects)
- create a new project
- verify in the
log/elasticsearch.log
that ONLY the project record is queued for indexing (not any associated records) - verify that now one more project exists in the index but no associated data
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Terri Chu