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
192cf86b
Commit
192cf86b
authored
Dec 11, 2020
by
Changzheng Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set default query string when searching with filters
parent
54b2e5a8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
0 deletions
+24
-0
ee/changelogs/unreleased/258377_search_filter_defaults.yml
ee/changelogs/unreleased/258377_search_filter_defaults.yml
+5
-0
ee/spec/models/concerns/elastic/repository_spec.rb
ee/spec/models/concerns/elastic/repository_spec.rb
+18
-0
lib/gitlab/search/query.rb
lib/gitlab/search/query.rb
+1
-0
No files found.
ee/changelogs/unreleased/258377_search_filter_defaults.yml
0 → 100644
View file @
192cf86b
---
title
:
Set default query string when searching with filters
merge_request
:
49872
author
:
type
:
added
ee/spec/models/concerns/elastic/repository_spec.rb
View file @
192cf86b
...
...
@@ -63,6 +63,24 @@ RSpec.describe Repository, :elastic do
# Finds files/ruby/popen.rb
expect
(
project
.
repository
.
elastic_search
(
'* blob:7e3e39ebb9b2bf433b4ad17313770fbe4051649c'
)[
:blobs
][
:total_count
]).
to
eq
(
1
)
# filename filter without search term
count
=
project
.
repository
.
ls_files
(
'master'
).
count
{
|
path
|
path
.
split
(
'/'
)[
-
1
].
include?
(
'test'
)
}
expect
(
project
.
repository
.
elastic_search
(
'filename:test'
)[
:blobs
][
:total_count
]).
to
eq
(
count
)
expect
(
project
.
repository
.
elastic_search
(
'filename:test'
)[
:blobs
][
:total_count
]).
to
be
>
0
# extension filter without search term
count
=
project
.
repository
.
ls_files
(
'master'
).
count
{
|
path
|
path
.
split
(
'/'
)[
-
1
].
split
(
'.'
)[
-
1
].
include?
(
'md'
)
}
expect
(
project
.
repository
.
elastic_search
(
'extension:md'
)[
:blobs
][
:total_count
]).
to
eq
(
count
)
expect
(
project
.
repository
.
elastic_search
(
'extension:md'
)[
:blobs
][
:total_count
]).
to
be
>
0
# path filter without search term
count
=
project
.
repository
.
ls_files
(
'master'
).
count
{
|
path
|
path
.
include?
(
'ruby'
)
}
expect
(
project
.
repository
.
elastic_search
(
'path:ruby'
)[
:blobs
][
:total_count
]).
to
eq
(
count
)
expect
(
project
.
repository
.
elastic_search
(
'path:ruby'
)[
:blobs
][
:total_count
]).
to
be
>
0
# blob filter without search term
expect
(
project
.
repository
.
elastic_search
(
'blob:7e3e39ebb9b2bf433b4ad17313770fbe4051649c'
)[
:blobs
][
:total_count
]).
to
eq
(
1
)
end
def
search_and_check!
(
on
,
query
,
type
:,
per:
1000
)
...
...
lib/gitlab/search/query.rb
View file @
192cf86b
...
...
@@ -51,6 +51,7 @@ module Gitlab
end
query
=
(
@raw_query
.
split
-
fragments
).
join
(
' '
)
query
=
'*'
if
query
.
empty?
[
query
,
filters
]
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