Skip to content
Snippets Groups Projects
Commit e357a1a0 authored by Valery Sizov's avatar Valery Sizov
Browse files

Merge branch 'filename_search' into 'master'

Search through the filenames

https://gitlab.com/gitlab-org/gitlab-ee/issues/295

See merge request !12
parents b46dc530 55d17217
No related branches found
No related tags found
1 merge request!12Search through the filenames
0.0.15
- Search through the filenames
0.0.14
- Improve code search analyzer (custom word delimeter of source code)
- Fix encoding issues
Loading
Loading
Loading
Loading
@@ -28,6 +28,7 @@ module Elasticsearch
indexes :oid, type: :string, index_options: 'offsets', analyzer: :code_analyzer
indexes :commit_sha, type: :string, index_options: 'offsets', analyzer: :sha_analyzer
indexes :path, type: :string, analyzer: :path_analyzer
indexes :file_name, type: :string, analyzer: :code_analyzer
indexes :content, type: :string, index_options: 'offsets', analyzer: :code_analyzer
indexes :language, type: :string, index: :not_analyzed
end
Loading
Loading
@@ -119,6 +120,15 @@ module Elasticsearch
content: blob.data,
commit_sha: target_sha,
path: blob.path,
# We're duplicating file_name parameter here because
# we need another analyzer for it.
# Ideally this should be done with copy_to: 'blob.file_name' option
# but it does not work in ES v2.3.*. We're doing it so to not make users
# install newest versions
# https://github.com/elastic/elasticsearch-mapper-attachments/issues/124
file_name: blob.path,
language: blob.language ? blob.language.name : "Text"
}
}
Loading
Loading
@@ -455,7 +465,7 @@ module Elasticsearch
multi_match: {
query: query,
operator: :and,
fields: [ 'blob.content', 'blob.path' ]
fields: [ 'blob.content', 'blob.file_name' ]
}
}
}
Loading
Loading
@@ -517,7 +527,7 @@ module Elasticsearch
post_tags: ["←gitlabelasticsearch"],
fields: {
"blob.content" => {},
"blob.path" => {},
"blob.file_name" => {},
"type" => "fvh",
"boundary_chars" => "\n"
}
Loading
Loading
Loading
Loading
@@ -42,6 +42,19 @@ describe TestRepository do
expect(repo.search('def')[:blobs][:total_count]).to eq(4)
end
 
it "searches through filename" do
repo = TestRepository.new
repo.index_blobs
TestRepository.__elasticsearch__.refresh_index!
found_version_file = repo.search('version')[:blobs][:results].any? do |result|
result["_source"]["blob"]["file_name"] == "VERSION"
end
expect(found_version_file).to be_truthy
end
it "indexes specified commits" do
repo = TestRepository.new
repo.index_commits(
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment