Commit 49a4bda0 authored by Terri Chu's avatar Terri Chu Committed by Dmitry Gruzd

Add blob search aggregations for language

parent 91d34066
---
name: search_blobs_language_aggregation
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/71937
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/342621
milestone: '14.4'
type: development
group: group::global search
default_enabled: false
...@@ -201,6 +201,24 @@ module Elastic ...@@ -201,6 +201,24 @@ module Elastic
} }
end end
if type == 'blob' && !options[:count_only] && ::Feature.enabled?(:search_blobs_language_aggregation, options[:current_user], default_enabled: :yaml)
query_hash[:aggs] = {
language: {
composite: {
sources: [
{
language: {
terms: {
field: 'blob.language'
}
}
}
]
}
}
}
end
# inject the `id` part of repository as project id # inject the `id` part of repository as project id
repository_ids = [options[:repository_id]].flatten repository_ids = [options[:repository_id]].flatten
options[:project_ids] = repository_ids.map { |id| id.to_s[/\d+/].to_i } if type == 'wiki_blob' && repository_ids.any? options[:project_ids] = repository_ids.map { |id| id.to_s[/\d+/].to_i } if type == 'wiki_blob' && repository_ids.any?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment