Advanced search - Allow sorting work items by title
Description
When trying to sort work items by their title via ES, you get the following error:
Elasticsearch::Transport::Transport::Errors::BadRequest ([400] {"error":{"root_cause":
[{"type":"illegal_argument_exception","reason":"Fielddata is disabled on [title] in
[gitlab-development-work_items-20250603-1019]. Text fields are not optimised for operations
that require per-document field data like aggregations and sorting, so these operations
are disabled by default. Please use a keyword field instead.
Alternatively, set fielddata=true on [title] in order to load field data by
uninverting the inverted index. Note that this can use significant memory."}]My proposal is to add keyword type for the title alongside with the existing text type in ee/lib/search/elastic/types/work_item.rb
title: { type: 'text', index_options: 'positions', analyzer: :title_analyzer, fields: { keyword: { type: 'keyword' } } }title #562593 (comment 2698211747).
Implementation
- Please refer to this issue description for the steps on how to add new mapping and backfill data in ES #540799
- After the data is migrated, we'll have to allow
title_descandtitle_ascinAdvancedFinders::WorkItemsFinderinSORT_KEYS. - Then we'll need to update mappings in
ee/lib/search/elastic/sorts.rbandlib/gitlab/search/sort_options.rb.
Edited by 🤖 GitLab Bot 🤖