Commit fdf5d094 authored by Dmitry Gruzd's avatar Dmitry Gruzd Committed by Dylan Griffith

Advanced Search: Add meta field to indices mapping

parent fbc64cb4
......@@ -247,6 +247,12 @@ module Gitlab
client.indices.put_mapping(index: index_name || target_index_name, body: mappings)
end
def get_meta(index_name: nil)
index = target_index_name(target: index_name)
mappings = client.indices.get_mapping(index: index)
mappings.dig(index, 'mappings', '_meta')
end
def switch_alias(from: target_index_name, alias_name: target_name, to:)
actions = [
{
......@@ -297,11 +303,19 @@ module Gitlab
settings.merge!(options[:settings]) if options[:settings]
mappings.merge!(options[:mappings]) if options[:mappings]
meta_info = {
doc: {
_meta: {
created_by: Gitlab::VERSION
}
}
}
create_index_options = {
index: index_name,
body: {
settings: settings,
mappings: mappings
mappings: mappings.deep_merge(meta_info)
}
}.merge(additional_index_options)
......
......@@ -386,4 +386,12 @@ RSpec.describe Gitlab::Elastic::Helper, :request_store do
expect { subject }.not_to raise_exception
end
end
describe '#get_meta', :elastic do
subject { helper.get_meta }
it 'returns version in meta field' do
is_expected.to include('created_by' => Gitlab::VERSION)
end
end
end
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