Commit 759db2da authored by Dmitry Gruzd's avatar Dmitry Gruzd

Merge branch '340333-add-language-aggregations-for-blob-search' into 'master'

Add blob search aggregations for language

See merge request gitlab-org/gitlab!71937
parents 352dc136 49a4bda0
---
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
}
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
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?
......
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