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
656454bd
Commit
656454bd
authored
Nov 01, 2021
by
Dmitry Gruzd
Committed by
Terri Chu
Nov 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove type filter from issues/mr/notes ES queries
parent
4a4b80a6
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
54 additions
and
44 deletions
+54
-44
ee/lib/elastic/latest/application_class_proxy.rb
ee/lib/elastic/latest/application_class_proxy.rb
+38
-28
ee/lib/elastic/latest/issue_class_proxy.rb
ee/lib/elastic/latest/issue_class_proxy.rb
+4
-3
ee/lib/elastic/latest/merge_request_class_proxy.rb
ee/lib/elastic/latest/merge_request_class_proxy.rb
+4
-3
ee/lib/elastic/latest/milestone_class_proxy.rb
ee/lib/elastic/latest/milestone_class_proxy.rb
+1
-1
ee/lib/elastic/latest/note_class_proxy.rb
ee/lib/elastic/latest/note_class_proxy.rb
+3
-2
ee/lib/elastic/latest/project_class_proxy.rb
ee/lib/elastic/latest/project_class_proxy.rb
+1
-1
ee/spec/models/concerns/elastic/issue_spec.rb
ee/spec/models/concerns/elastic/issue_spec.rb
+1
-2
ee/spec/models/concerns/elastic/merge_request_spec.rb
ee/spec/models/concerns/elastic/merge_request_spec.rb
+1
-2
ee/spec/models/concerns/elastic/note_spec.rb
ee/spec/models/concerns/elastic/note_spec.rb
+1
-2
No files found.
ee/lib/elastic/latest/application_class_proxy.rb
View file @
656454bd
...
...
@@ -65,10 +65,10 @@ module Elastic
}
end
def
basic_query_hash
(
fields
,
query
,
count_only:
false
)
def
basic_query_hash
(
fields
,
query
,
options
=
{}
)
fields
=
CustomLanguageAnalyzers
.
add_custom_analyzers_fields
(
fields
)
fields
=
remove_fields_boost
(
fields
)
if
count_only
fields
=
remove_fields_boost
(
fields
)
if
options
[
:count_only
]
query_hash
=
if
query
.
present?
...
...
@@ -82,18 +82,46 @@ module Elastic
}
}
build_query_filter
(
simple_query_string
,
options
)
else
{
query:
{
bool:
{
must:
{
match_all:
{}
}
}
},
track_scores:
true
}
end
if
options
[
:count_only
]
query_hash
[
:size
]
=
0
else
query_hash
[
:highlight
]
=
highlight_options
(
fields
)
end
query_hash
end
def
build_query_filter
(
simple_query_string
,
options
)
must
=
[]
filter
=
[{
filter
=
if
options
[
:no_join_project
]
[]
else
[
{
term:
{
type:
{
_name:
context
.
name
(
:doc
,
:is_a
,
self
.
es_type
),
value:
self
.
es_type
}
}
}]
}
]
end
if
count_only
if
options
[
:count_only
]
filter
<<
simple_query_string
else
must
<<
simple_query_string
...
...
@@ -107,24 +135,6 @@ module Elastic
}
}
}
else
{
query:
{
bool:
{
must:
{
match_all:
{}
}
}
},
track_scores:
true
}
end
if
count_only
query_hash
[
:size
]
=
0
else
query_hash
[
:highlight
]
=
highlight_options
(
fields
)
end
query_hash
end
def
iid_query_hash
(
iid
)
...
...
ee/lib/elastic/latest/issue_class_proxy.rb
View file @
656454bd
...
...
@@ -6,6 +6,9 @@ module Elastic
include
StateFilter
def
elastic_search
(
query
,
options:
{})
options
[
:features
]
=
'issues'
options
[
:no_join_project
]
=
true
query_hash
=
if
query
=~
/#(\d+)\z/
iid_query_hash
(
Regexp
.
last_match
(
1
))
...
...
@@ -13,11 +16,9 @@ module Elastic
# iid field can be added here as lenient option will
# pardon format errors, like integer out of range.
fields
=
%w[iid^3 title^2 description]
basic_query_hash
(
fields
,
query
,
count_only:
options
[
:count_only
]
)
basic_query_hash
(
fields
,
query
,
options
)
end
options
[
:features
]
=
'issues'
options
[
:no_join_project
]
=
true
context
.
name
(
:issue
)
do
query_hash
=
context
.
name
(
:authorized
)
{
authorization_filter
(
query_hash
,
options
)
}
query_hash
=
context
.
name
(
:confidentiality
)
{
confidentiality_filter
(
query_hash
,
options
)
}
...
...
ee/lib/elastic/latest/merge_request_class_proxy.rb
View file @
656454bd
...
...
@@ -6,6 +6,9 @@ module Elastic
include
StateFilter
def
elastic_search
(
query
,
options:
{})
options
[
:features
]
=
'merge_requests'
options
[
:no_join_project
]
=
Elastic
::
DataMigrationService
.
migration_has_finished?
(
:add_new_data_to_merge_requests_documents
)
query_hash
=
if
query
=~
/\!(\d+)\z/
iid_query_hash
(
Regexp
.
last_match
(
1
))
...
...
@@ -14,11 +17,9 @@ module Elastic
# pardon format errors, like integer out of range.
fields
=
%w[iid^3 title^2 description]
basic_query_hash
(
fields
,
query
,
count_only:
options
[
:count_only
]
)
basic_query_hash
(
fields
,
query
,
options
)
end
options
[
:features
]
=
'merge_requests'
options
[
:no_join_project
]
=
Elastic
::
DataMigrationService
.
migration_has_finished?
(
:add_new_data_to_merge_requests_documents
)
context
.
name
(
:merge_request
)
do
query_hash
=
context
.
name
(
:authorized
)
{
project_ids_filter
(
query_hash
,
options
)
}
query_hash
=
context
.
name
(
:match
)
{
state_filter
(
query_hash
,
options
)
}
...
...
ee/lib/elastic/latest/milestone_class_proxy.rb
View file @
656454bd
...
...
@@ -6,7 +6,7 @@ module Elastic
def
elastic_search
(
query
,
options:
{})
options
[
:in
]
=
%w[title^2 description]
query_hash
=
basic_query_hash
(
options
[
:in
],
query
,
count_only:
options
[
:count_only
]
)
query_hash
=
basic_query_hash
(
options
[
:in
],
query
,
options
)
query_hash
=
context
.
name
(
:milestone
,
:related
)
{
project_ids_filter
(
query_hash
,
options
)
}
search
(
query_hash
,
options
)
...
...
ee/lib/elastic/latest/note_class_proxy.rb
View file @
656454bd
...
...
@@ -11,9 +11,10 @@ module Elastic
def
elastic_search
(
query
,
options:
{})
options
[
:in
]
=
[
'note'
]
query_hash
=
basic_query_hash
(
%w[note]
,
query
,
count_only:
options
[
:count_only
])
options
[
:no_join_project
]
=
true
query_hash
=
basic_query_hash
(
%w[note]
,
query
,
options
)
context
.
name
(
:note
)
do
query_hash
=
context
.
name
(
:authorized
)
{
project_ids_filter
(
query_hash
,
options
)
}
query_hash
=
context
.
name
(
:confidentiality
)
{
confidentiality_filter
(
query_hash
,
options
)
}
...
...
ee/lib/elastic/latest/project_class_proxy.rb
View file @
656454bd
...
...
@@ -6,7 +6,7 @@ module Elastic
def
elastic_search
(
query
,
options:
{})
options
[
:in
]
=
%w[name^10 name_with_namespace^2 path_with_namespace path^9 description]
query_hash
=
basic_query_hash
(
options
[
:in
],
query
,
count_only:
options
[
:count_only
]
)
query_hash
=
basic_query_hash
(
options
[
:in
],
query
,
options
)
filters
=
[{
terms:
{
_name:
context
.
name
(
:doc
,
:is_a
,
es_type
),
type:
[
es_type
]
}
}]
...
...
ee/spec/models/concerns/elastic/issue_spec.rb
View file @
656454bd
...
...
@@ -78,8 +78,7 @@ RSpec.describe Issue, :elastic do
it
"names elasticsearch queries"
do
described_class
.
elastic_search
(
'*'
).
total_count
assert_named_queries
(
'doc:is_a:issue'
,
'issue:match:search_terms'
,
assert_named_queries
(
'issue:match:search_terms'
,
'issue:authorized:project'
)
end
...
...
ee/spec/models/concerns/elastic/merge_request_spec.rb
View file @
656454bd
...
...
@@ -43,8 +43,7 @@ RSpec.describe MergeRequest, :elastic do
it
"names elasticsearch queries"
do
described_class
.
elastic_search
(
'*'
).
total_count
assert_named_queries
(
'doc:is_a:merge_request'
,
'merge_request:match:search_terms'
,
assert_named_queries
(
'merge_request:match:search_terms'
,
'merge_request:authorized:project'
)
end
...
...
ee/spec/models/concerns/elastic/note_spec.rb
View file @
656454bd
...
...
@@ -58,8 +58,7 @@ RSpec.describe Note, :elastic, :clean_gitlab_redis_shared_state do
it
"names elasticsearch queries"
do
described_class
.
elastic_search
(
'*'
).
total_count
assert_named_queries
(
"doc:is_a:note"
,
"note:match:search_terms"
,
assert_named_queries
(
"note:match:search_terms"
,
"note:authorized"
)
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