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
ab6b7025
Commit
ab6b7025
authored
Jun 07, 2017
by
Valery Sizov
Committed by
Sean McGivern
Jun 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Elasticsearch] Improve code search for camel case
parent
818f0655
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
2 deletions
+51
-2
changelogs/unreleased-ee/improve_code_search_for_camel_case.yml
...logs/unreleased-ee/improve_code_search_for_camel_case.yml
+4
-0
lib/elasticsearch/git/model.rb
lib/elasticsearch/git/model.rb
+8
-2
spec/lib/gitlab/elastic/search_results_spec.rb
spec/lib/gitlab/elastic/search_results_spec.rb
+39
-0
No files found.
changelogs/unreleased-ee/improve_code_search_for_camel_case.yml
0 → 100644
View file @
ab6b7025
---
title
:
"
[Elasticsearch]
Improve
code
search
for
camel
case"
merge_request
:
author
:
lib/elasticsearch/git/model.rb
View file @
ab6b7025
...
...
@@ -33,7 +33,7 @@ module Elasticsearch
code_analyzer:
{
type:
'custom'
,
tokenizer:
'standard'
,
filter:
%w(code lowercase asciifolding)
,
filter:
%w(code
edgeNGram_filter
lowercase asciifolding)
,
char_filter:
[
"code_mapping"
]
},
code_search_analyzer:
{
...
...
@@ -61,8 +61,14 @@ module Elasticsearch
preserve_original:
1
,
patterns:
[
"(
\\
p{Ll}+|
\\
p{Lu}
\\
p{Ll}+|
\\
p{Lu}+)"
,
"(
\\
d+)"
"(
\\
d+)"
,
"(?=([
\\
p{Lu}]+[
\\
p{L}]+))"
]
},
edgeNGram_filter:
{
type:
'edgeNGram'
,
min_gram:
2
,
max_gram:
40
}
},
char_filter:
{
...
...
spec/lib/gitlab/elastic/search_results_spec.rb
View file @
ab6b7025
...
...
@@ -399,6 +399,45 @@ describe Gitlab::Elastic::SearchResults, lib: true do
expect
(
results
.
blobs_count
).
to
eq
0
end
context
'Searches CamelCased methods'
do
before
do
project_1
.
repository
.
create_file
(
user
,
'test.txt'
,
' function writeStringToFile(){} '
,
message:
'added test file'
,
branch_name:
'master'
)
project_1
.
repository
.
index_blobs
Gitlab
::
Elastic
::
Helper
.
refresh_index
end
def
search_for
(
term
)
blobs
=
described_class
.
new
(
user
,
term
,
[
project_1
.
id
]).
objects
(
'blobs'
)
blobs
.
map
do
|
blob
|
blob
[
"_source"
][
"blob"
][
"path"
]
end
end
it
'find by first word'
do
expect
(
search_for
(
'write'
)).
to
include
(
'test.txt'
)
end
it
'find by first two words'
do
expect
(
search_for
(
'writeString'
)).
to
include
(
'test.txt'
)
end
it
'find by last two words'
do
expect
(
search_for
(
'ToFile'
)).
to
include
(
'test.txt'
)
end
it
'find by exact match'
do
expect
(
search_for
(
'writeStringToFile'
)).
to
include
(
'test.txt'
)
end
end
end
describe
'Wikis'
do
...
...
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