Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
fdf5d094
Commit
fdf5d094
authored
Dec 23, 2021
by
Dmitry Gruzd
Committed by
Dylan Griffith
Dec 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Advanced Search: Add meta field to indices mapping
parent
fbc64cb4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
ee/lib/gitlab/elastic/helper.rb
ee/lib/gitlab/elastic/helper.rb
+15
-1
ee/spec/lib/ee/gitlab/elastic/helper_spec.rb
ee/spec/lib/ee/gitlab/elastic/helper_spec.rb
+8
-0
No files found.
ee/lib/gitlab/elastic/helper.rb
View file @
fdf5d094
...
...
@@ -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
)
...
...
ee/spec/lib/ee/gitlab/elastic/helper_spec.rb
View file @
fdf5d094
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment