gitlab-elasticsearch-git 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba4d3958d1aa1aa5ebc18dd268708607ea22cf59
4
- data.tar.gz: a40a0d48a99aaf2d876ed4d733acf41e2b78ee8e
3
+ metadata.gz: 805299d2c9977f838c91ad88a5ae27415345ad8d
4
+ data.tar.gz: f4c2c5211cb767f10042b1373d4ebbcafe9e0b89
5
5
  SHA512:
6
- metadata.gz: 90799948082455a0d6cde26b83b3f6b65664b3223ebd8e8edf8e4fbf6af8570c11d041874c088f2eac5d9608f0f7298f47ee1027482e6ad0000b8336e9dab6e7
7
- data.tar.gz: 5f7c8eec4c6b73be317eeb394c6f6f928d4976290f1824934d311b4c638eb7c8e445f0fabe5740d7b99e8a84a5ba0602ae99c9f1f874a1fb1d69f626a2729812
6
+ metadata.gz: 73ce23ee1c90b94713d5b4dc49878cb6a110de5ebec9a002abc423249532337e0cf544ff0e6bb6b43c118373afd27b34e87645bb4e6a6b1c080e7497287e1b99
7
+ data.tar.gz: 9e1227a3b202f421667e45e3adfa1bef6db62096f2f00ab8eae3c35bafe60ef12b92bdc533413ccbcb1ead5f5e0d48f1d40b049a96d0ba032c64a05127002a34
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 0.0.15
2
+ - Search through the filenames
3
+
1
4
  0.0.14
2
5
  - Improve code search analyzer (custom word delimeter of source code)
3
6
  - Fix encoding issues
@@ -28,6 +28,7 @@ module Elasticsearch
28
28
  indexes :oid, type: :string, index_options: 'offsets', analyzer: :code_analyzer
29
29
  indexes :commit_sha, type: :string, index_options: 'offsets', analyzer: :sha_analyzer
30
30
  indexes :path, type: :string, analyzer: :path_analyzer
31
+ indexes :file_name, type: :string, analyzer: :code_analyzer
31
32
  indexes :content, type: :string, index_options: 'offsets', analyzer: :code_analyzer
32
33
  indexes :language, type: :string, index: :not_analyzed
33
34
  end
@@ -119,6 +120,15 @@ module Elasticsearch
119
120
  content: blob.data,
120
121
  commit_sha: target_sha,
121
122
  path: blob.path,
123
+
124
+ # We're duplicating file_name parameter here because
125
+ # we need another analyzer for it.
126
+ # Ideally this should be done with copy_to: 'blob.file_name' option
127
+ # but it does not work in ES v2.3.*. We're doing it so to not make users
128
+ # install newest versions
129
+ # https://github.com/elastic/elasticsearch-mapper-attachments/issues/124
130
+ file_name: blob.path,
131
+
122
132
  language: blob.language ? blob.language.name : "Text"
123
133
  }
124
134
  }
@@ -455,7 +465,7 @@ module Elasticsearch
455
465
  multi_match: {
456
466
  query: query,
457
467
  operator: :and,
458
- fields: [ 'blob.content', 'blob.path' ]
468
+ fields: [ 'blob.content', 'blob.file_name' ]
459
469
  }
460
470
  }
461
471
  }
@@ -517,7 +527,7 @@ module Elasticsearch
517
527
  post_tags: ["←gitlabelasticsearch"],
518
528
  fields: {
519
529
  "blob.content" => {},
520
- "blob.path" => {},
530
+ "blob.file_name" => {},
521
531
  "type" => "fvh",
522
532
  "boundary_chars" => "\n"
523
533
  }
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module Git
3
- VERSION = "0.0.14"
3
+ VERSION = '0.0.15'
4
4
  end
5
5
  end
data/spec/main_spec.rb CHANGED
@@ -42,6 +42,19 @@ describe TestRepository do
42
42
  expect(repo.search('def')[:blobs][:total_count]).to eq(4)
43
43
  end
44
44
 
45
+ it "searches through filename" do
46
+ repo = TestRepository.new
47
+ repo.index_blobs
48
+
49
+ TestRepository.__elasticsearch__.refresh_index!
50
+
51
+ found_version_file = repo.search('version')[:blobs][:results].any? do |result|
52
+ result["_source"]["blob"]["file_name"] == "VERSION"
53
+ end
54
+
55
+ expect(found_version_file).to be_truthy
56
+ end
57
+
45
58
  it "indexes specified commits" do
46
59
  repo = TestRepository.new
47
60
  repo.index_commits(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-elasticsearch-git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Kumanyaev
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-05-11 00:00:00.000000000 Z
13
+ date: 2016-05-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: elasticsearch-model