Verified Solution[gitlab-org/gitlab] Update advanced search migration framework to conditionally use DOC_TYPE
Sponsored Content
### ROOT CAUSE
The issue arises because the advanced search migration framework requires `DOC_TYPE` for all indexes, which is unnecessary for dedicated indexes (e.g., `vulnerability_reads`). This inefficiency stems from two main reasons: (1) the shared index (`main`) requires `DOC_TYPE` to distinguish multiple data types, and (2) `DOC_TYPE` is used to exclude validation records. However, dedicated indexes waste storage by including unused fields and prevent the creation of new indexes without `DOC_TYPE`.
### CODE FIX
To conditionally use `DOC_TYPE` in the migration framework, modify the framework to check if the index is dedicated (i.e., handles a single document type). For dedicated indexes, omit `DOC_TYPE` during backfill/migration. For the shared index, retain `DOC_TYPE` for validation and type distinction.
**Changes:**
1. **Index Configuration**: Add a flag (e.g., `requires_doc_type`) to index definitions to mark shared vs. dedicated indexes.
2. **Migration Framework**: Update the framework to use `DOC_TYPE` only when the index requires it. For dedicated indexes, skip validation records and `DOC_TYPE` entirely.
**Example Code Snippet (Pseudocode):**
```ruby
# In index definition
class VulnerabilityReadsIndex < SearchIndex
requires_doc_type false # Mark as dedicated
end
# In migration framework
def migrate(index)
if index.requires_doc_type
# Use DOC_TYPE logic for shared indexes
else
# Skip DOC_TYPE for dedicated indexes
end
end
```
This change ensures dedicated indexes are created without `DOC_TYPE`, optimizing storage and enabling seamless migration.
Deploy on DigitalOcean ($200 Credit)
Related Fixes
[StackOverflow/python] Fullbody Detection Using OpenCV Haar Cascades
[golang/go] x/vuln: fails just released go1.25.8 with 2 CVEs
[StackOverflow/python] Modify a bar plot into a stacked plot keeping the original values