Closed issue was returned when searching open issues using Advanced Search
Summary
When using Issues status filter and selecting Open
in the search result page, I found some closed issues were returned in the search result.
Steps to reproduce
- Search "archived project" for issues using Advanced Search in gitlab project
- On the search result page, narrow down the search result by choosing
Open
in the status filter
What is the current bug behavior?
- There are
Closed
issues returned in the search result.
What is the expected correct behavior?
- Only open issues in the search result.
Relevant logs and/or screenshots
Research
At this time there are 7 data objects which are being routed to the issues index: issue
, incident
, test_case
, requirement
, task
, objective
, key_result
. Note objective
and key_result
are only present for self-managed instances when OKR feature is enabled
I created one type of each item in a local gdk instance and all of them come back in issue search
Proposal
Note: Keep indexing all data that is currently indexed into the gitlab-<environment>-issues
index
- Override
es_id
method inIssueInstanceProxy
to use justissue.id
. Since the only documents in the index come from theissues
table, there is no need to have the type in the id. This will help avoid issues if more issue types get added (or if an issue is converted to an incident). Also update theSCHEMA_VERSION
to a new value - Add an Advanced search migration to add a new field to the issues index:
work_item_type_id
. This can be used to figure out the type fromWorkItems::Type
- Add the new field to
IssueInstanceProxy
only if the migration above is completed - Create two Advanced search migrations. Note they must run one after the other to reduce time where duplicate records exist.
- Reindex all issues - This can be a new little migration helper (if one was not already created), which can also be quite useful for indexing all documents of a specific type. We can add a configuration option so that we can specify whether it should respect elasticsearch limiting rules and
SCHEMA_VERSION
.- Allow
SCHEMA_VERSION
to be unset in the migration, if this is true the helper will do no clean up. Be sure to check for emptySCHEMA_VERSION
and less than as a document that needs to be updated. - If
SCHEMA_VERSION
is set, it is used to clean up existing data when everything needs to be re-indexed. - For elasticsearch limiting rules, for projects it would be set to
false
to not respect the limiting and issues it will be set totrue
- Allow
- Drop documents with older schema_version from the issues index. This should also be a helper since it will being useful for other document types
- Reindex all issues - This can be a new little migration helper (if one was not already created), which can also be quite useful for indexing all documents of a specific type. We can add a configuration option so that we can specify whether it should respect elasticsearch limiting rules and
- Create an MR to not set the
type
field for the issue documents and remove it from mappings, it's not useful due to how work_item_type work
Edited by Terri Chu