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
2e3ff160
Commit
2e3ff160
authored
Jul 24, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ES: allow global search on notes
Allow SearchResults to support notes
parent
55cb82cf
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
1 deletion
+89
-1
ee/app/services/ee/search/global_service.rb
ee/app/services/ee/search/global_service.rb
+1
-1
ee/app/views/search/_category_elasticsearch.html.haml
ee/app/views/search/_category_elasticsearch.html.haml
+5
-0
ee/changelogs/unreleased/11793-elasticsearch-restore-global-notes-search.yml
...eased/11793-elasticsearch-restore-global-notes-search.yml
+5
-0
ee/lib/gitlab/elastic/search_results.rb
ee/lib/gitlab/elastic/search_results.rb
+12
-0
ee/spec/features/search/elastic/global_search_spec.rb
ee/spec/features/search/elastic/global_search_spec.rb
+20
-0
ee/spec/lib/gitlab/elastic/search_results_spec.rb
ee/spec/lib/gitlab/elastic/search_results_spec.rb
+46
-0
No files found.
ee/app/services/ee/search/global_service.rb
View file @
2e3ff160
...
@@ -43,7 +43,7 @@ module EE
...
@@ -43,7 +43,7 @@ module EE
def
allowed_scopes
def
allowed_scopes
strong_memoize
(
:ee_allowed_scopes
)
do
strong_memoize
(
:ee_allowed_scopes
)
do
super
.
tap
do
|
ce_scopes
|
super
.
tap
do
|
ce_scopes
|
ce_scopes
.
concat
(
%w[wiki_blobs blobs commits]
)
if
::
Gitlab
::
CurrentSettings
.
elasticsearch_search?
ce_scopes
.
concat
(
%w[
notes
wiki_blobs blobs commits]
)
if
::
Gitlab
::
CurrentSettings
.
elasticsearch_search?
end
end
end
end
end
end
...
...
ee/app/views/search/_category_elasticsearch.html.haml
View file @
2e3ff160
-
if
search_service
.
use_elasticsearch?
-
if
search_service
.
use_elasticsearch?
%li
{
class:
active_when
(
@scope
==
'notes'
)
}
=
link_to
search_filter_path
(
scope:
'notes'
)
do
=
_
(
"Comments"
)
%span
.badge.badge-pill
=
limited_count
(
@search_results
.
notes_count
)
%li
{
class:
active_when
(
@scope
==
'blobs'
)
}
%li
{
class:
active_when
(
@scope
==
'blobs'
)
}
=
link_to
search_filter_path
(
scope:
'blobs'
)
do
=
link_to
search_filter_path
(
scope:
'blobs'
)
do
=
_
(
"Code"
)
=
_
(
"Code"
)
...
...
ee/changelogs/unreleased/11793-elasticsearch-restore-global-notes-search.yml
0 → 100644
View file @
2e3ff160
---
title
:
Allow global search on comments
merge_request
:
14818
author
:
type
:
added
ee/lib/gitlab/elastic/search_results.rb
View file @
2e3ff160
...
@@ -34,6 +34,8 @@ module Gitlab
...
@@ -34,6 +34,8 @@ module Gitlab
eager_load
(
merge_requests
,
page
,
eager:
{
target_project:
[
:route
,
:namespace
]
})
eager_load
(
merge_requests
,
page
,
eager:
{
target_project:
[
:route
,
:namespace
]
})
when
'milestones'
when
'milestones'
eager_load
(
milestones
,
page
,
eager:
{
project:
[
:route
,
:namespace
]
})
eager_load
(
milestones
,
page
,
eager:
{
project:
[
:route
,
:namespace
]
})
when
'notes'
eager_load
(
notes
,
page
,
eager:
{
project:
[
:route
,
:namespace
]
})
when
'blobs'
when
'blobs'
blobs
.
page
(
page
).
per
(
per_page
)
blobs
.
page
(
page
).
per
(
per_page
)
when
'wiki_blobs'
when
'wiki_blobs'
...
@@ -56,6 +58,10 @@ module Gitlab
...
@@ -56,6 +58,10 @@ module Gitlab
end
end
alias_method
:limited_projects_count
,
:projects_count
alias_method
:limited_projects_count
,
:projects_count
def
notes_count
@notes_count
||=
notes
.
total_count
end
def
blobs_count
def
blobs_count
@blobs_count
||=
blobs
.
total_count
@blobs_count
||=
blobs
.
total_count
end
end
...
@@ -191,6 +197,12 @@ module Gitlab
...
@@ -191,6 +197,12 @@ module Gitlab
end
end
end
end
def
notes
strong_memoize
(
:notes
)
do
Note
.
elastic_search
(
query
,
options:
base_options
)
end
end
def
blobs
def
blobs
return
Kaminari
.
paginate_array
([])
if
query
.
blank?
return
Kaminari
.
paginate_array
([])
if
query
.
blank?
...
...
ee/spec/features/search/elastic/global_search_spec.rb
View file @
2e3ff160
...
@@ -88,6 +88,26 @@ describe 'Global elastic search', :elastic do
...
@@ -88,6 +88,26 @@ describe 'Global elastic search', :elastic do
end
end
end
end
describe
'I search through the notes and I see pagination'
do
before
do
issue
=
create
(
:issue
,
project:
project
,
title:
'initial'
)
create_list
(
:note
,
21
,
noteable:
issue
,
project:
project
,
note:
'foo'
)
Gitlab
::
Elastic
::
Helper
.
refresh_index
end
it
"has a pagination"
do
visit
dashboard_projects_path
fill_in
"search"
,
with:
"foo"
click_button
"Go"
select_filter
(
"Comments"
)
expect
(
page
).
to
have_selector
(
'.gl-pagination .js-pagination-page'
,
count:
2
)
end
end
describe
'I search through the blobs'
do
describe
'I search through the blobs'
do
let
(
:project_2
)
{
create
(
:project
,
:repository
,
:wiki_repo
)
}
let
(
:project_2
)
{
create
(
:project
,
:repository
,
:wiki_repo
)
}
...
...
ee/spec/lib/gitlab/elastic/search_results_spec.rb
View file @
2e3ff160
...
@@ -144,6 +144,52 @@ describe Gitlab::Elastic::SearchResults, :elastic do
...
@@ -144,6 +144,52 @@ describe Gitlab::Elastic::SearchResults, :elastic do
end
end
end
end
describe
'notes'
do
let
(
:issue
)
{
create
(
:issue
,
project:
project_1
,
title:
'Hello'
)
}
before
do
@note_1
=
create
(
:note
,
noteable:
issue
,
project:
project_1
,
note:
'foo bar'
)
@note_2
=
create
(
:note_on_issue
,
noteable:
issue
,
project:
project_1
,
note:
'foo baz'
)
@note_3
=
create
(
:note_on_issue
,
noteable:
issue
,
project:
project_1
,
note:
'bar baz'
)
Gitlab
::
Elastic
::
Helper
.
refresh_index
end
it_behaves_like
'a paginated object'
,
'notes'
it
'lists found notes'
do
results
=
described_class
.
new
(
user
,
'foo'
,
limit_project_ids
)
notes
=
results
.
objects
(
'notes'
)
expect
(
notes
).
to
include
@note_1
expect
(
notes
).
to
include
@note_2
expect
(
notes
).
not_to
include
@note_3
expect
(
results
.
notes_count
).
to
eq
2
end
it
'returns empty list when notes are not found'
do
results
=
described_class
.
new
(
user
,
'security'
,
limit_project_ids
)
expect
(
results
.
objects
(
'notes'
)).
to
be_empty
expect
(
results
.
notes_count
).
to
eq
0
end
end
describe
'confidential issues'
do
describe
'confidential issues'
do
let
(
:project_3
)
{
create
(
:project
)
}
let
(
:project_3
)
{
create
(
:project
)
}
let
(
:project_4
)
{
create
(
:project
)
}
let
(
:project_4
)
{
create
(
:project
)
}
...
...
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