gitlab-elasticsearch-git 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +5 -0
- data/lib/elasticsearch/git/model.rb +11 -2
- data/lib/elasticsearch/git/repository.rb +22 -23
- data/lib/elasticsearch/git/version.rb +1 -1
- data/spec/main_spec.rb +30 -6
- data/spec/support/test_repository.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba4d3958d1aa1aa5ebc18dd268708607ea22cf59
|
4
|
+
data.tar.gz: a40a0d48a99aaf2d876ed4d733acf41e2b78ee8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90799948082455a0d6cde26b83b3f6b65664b3223ebd8e8edf8e4fbf6af8570c11d041874c088f2eac5d9608f0f7298f47ee1027482e6ad0000b8336e9dab6e7
|
7
|
+
data.tar.gz: 5f7c8eec4c6b73be317eeb394c6f6f928d4976290f1824934d311b4c638eb7c8e445f0fabe5740d7b99e8a84a5ba0602ae99c9f1f874a1fb1d69f626a2729812
|
data/CHANGELOG
CHANGED
@@ -42,7 +42,8 @@ module Elasticsearch
|
|
42
42
|
code_analyzer: {
|
43
43
|
type: 'custom',
|
44
44
|
tokenizer: 'standard',
|
45
|
-
filter: %w(lowercase asciifolding
|
45
|
+
filter: %w(lowercase asciifolding code_stemmer),
|
46
|
+
char_filter: ["code_mapping"]
|
46
47
|
}
|
47
48
|
},
|
48
49
|
tokenizer: {
|
@@ -68,7 +69,15 @@ module Elasticsearch
|
|
68
69
|
type: "stemmer",
|
69
70
|
name: "minimal_english"
|
70
71
|
}
|
71
|
-
}
|
72
|
+
},
|
73
|
+
char_filter: {
|
74
|
+
code_mapping: {
|
75
|
+
type: "mapping",
|
76
|
+
mappings: [
|
77
|
+
". => ' '"
|
78
|
+
]
|
79
|
+
}
|
80
|
+
},
|
72
81
|
}
|
73
82
|
}
|
74
83
|
end
|
@@ -184,13 +184,13 @@ module Elasticsearch
|
|
184
184
|
rid: repository_id,
|
185
185
|
sha: commit.oid,
|
186
186
|
author: {
|
187
|
-
name: commit.author[:name],
|
188
|
-
email: commit.author[:email],
|
187
|
+
name: encode!(commit.author[:name]),
|
188
|
+
email: encode!(commit.author[:email]),
|
189
189
|
time: commit.author[:time].strftime('%Y%m%dT%H%M%S%z'),
|
190
190
|
},
|
191
191
|
committer: {
|
192
|
-
name: commit.committer[:name],
|
193
|
-
email: commit.committer[:email],
|
192
|
+
name: encode!(commit.committer[:name]),
|
193
|
+
email: encode!(commit.committer[:email]),
|
194
194
|
time: commit.committer[:time].strftime('%Y%m%dT%H%M%S%z'),
|
195
195
|
},
|
196
196
|
message: encode!(commit.message)
|
@@ -312,7 +312,7 @@ module Elasticsearch
|
|
312
312
|
|
313
313
|
# Repository id used for identity data from different repositories
|
314
314
|
# Update this value if need
|
315
|
-
def set_repository_id
|
315
|
+
def set_repository_id(id = nil)
|
316
316
|
@repository_id = id || path_to_repo
|
317
317
|
end
|
318
318
|
|
@@ -375,15 +375,15 @@ module Elasticsearch
|
|
375
375
|
|
376
376
|
query_hash = {
|
377
377
|
query: {
|
378
|
-
|
379
|
-
|
378
|
+
bool: {
|
379
|
+
must: [{
|
380
380
|
multi_match: {
|
381
381
|
fields: fields,
|
382
382
|
query: "#{query}",
|
383
383
|
operator: :or
|
384
384
|
}
|
385
|
-
}
|
386
|
-
}
|
385
|
+
}]
|
386
|
+
}
|
387
387
|
},
|
388
388
|
aggs: {
|
389
389
|
commitRepositoryFaset: {
|
@@ -399,15 +399,14 @@ module Elasticsearch
|
|
399
399
|
}
|
400
400
|
|
401
401
|
if query.blank?
|
402
|
-
query_hash[:query][:
|
402
|
+
query_hash[:query][:bool][:must] = { match_all: {}}
|
403
403
|
query_hash[:track_scores] = true
|
404
404
|
end
|
405
405
|
|
406
406
|
if options[:repository_id]
|
407
|
-
query_hash[:query][:
|
408
|
-
query_hash[:query][:filtered][:filter][:and] << {
|
407
|
+
query_hash[:query][:bool][:filter] = {
|
409
408
|
terms: {
|
410
|
-
|
409
|
+
'commit.rid' => [options[:repository_id]].flatten
|
411
410
|
}
|
412
411
|
}
|
413
412
|
end
|
@@ -451,8 +450,8 @@ module Elasticsearch
|
|
451
450
|
|
452
451
|
query_hash = {
|
453
452
|
query: {
|
454
|
-
|
455
|
-
|
453
|
+
bool: {
|
454
|
+
must: {
|
456
455
|
multi_match: {
|
457
456
|
query: query,
|
458
457
|
operator: :and,
|
@@ -481,20 +480,20 @@ module Elasticsearch
|
|
481
480
|
from: per * (page - 1)
|
482
481
|
}
|
483
482
|
|
483
|
+
query_hash[:query][:bool][:filter] = []
|
484
|
+
|
484
485
|
if options[:repository_id]
|
485
|
-
query_hash[:query][:
|
486
|
-
query_hash[:query][:filtered][:filter][:and] << {
|
486
|
+
query_hash[:query][:bool][:filter] << {
|
487
487
|
terms: {
|
488
|
-
|
488
|
+
'blob.rid' => [options[:repository_id]].flatten
|
489
489
|
}
|
490
490
|
}
|
491
491
|
end
|
492
492
|
|
493
493
|
if options[:language]
|
494
|
-
query_hash[:query][:
|
495
|
-
query_hash[:query][:filtered][:filter][:and] << {
|
494
|
+
query_hash[:query][:bool][:filter] << {
|
496
495
|
terms: {
|
497
|
-
|
496
|
+
'blob.language' => [options[:language]].flatten
|
498
497
|
}
|
499
498
|
}
|
500
499
|
end
|
@@ -540,12 +539,12 @@ module Elasticsearch
|
|
540
539
|
fields: ['blob.path'],
|
541
540
|
query: {
|
542
541
|
fuzzy: {
|
543
|
-
|
542
|
+
'repository.blob.path' => { value: query }
|
544
543
|
},
|
545
544
|
},
|
546
545
|
filter: {
|
547
546
|
term: {
|
548
|
-
|
547
|
+
'repository.blob.rid' => [options[:repository_id]].flatten
|
549
548
|
}
|
550
549
|
},
|
551
550
|
size: per,
|
data/spec/main_spec.rb
CHANGED
@@ -27,7 +27,7 @@ describe TestRepository do
|
|
27
27
|
repo.index_commits
|
28
28
|
|
29
29
|
TestRepository.__elasticsearch__.refresh_index!
|
30
|
-
|
30
|
+
|
31
31
|
expect(repo.search('test', type: :commit)[:commits][:total_count]).to eq(2)
|
32
32
|
end
|
33
33
|
|
@@ -37,12 +37,12 @@ describe TestRepository do
|
|
37
37
|
repo.index_blobs
|
38
38
|
|
39
39
|
TestRepository.__elasticsearch__.refresh_index!
|
40
|
-
|
40
|
+
|
41
41
|
expect(repo.search('test')[:commits][:total_count]).to eq(2)
|
42
42
|
expect(repo.search('def')[:blobs][:total_count]).to eq(4)
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
45
|
+
it "indexes specified commits" do
|
46
46
|
repo = TestRepository.new
|
47
47
|
repo.index_commits(
|
48
48
|
from_rev: '40f4a7a617393735a95a0bb67b08385bc1e7c66d',
|
@@ -50,11 +50,11 @@ describe TestRepository do
|
|
50
50
|
)
|
51
51
|
|
52
52
|
TestRepository.__elasticsearch__.refresh_index!
|
53
|
-
|
53
|
+
|
54
54
|
expect(repo.search('empty', type: :commit)[:commits][:total_count]).to eq(1)
|
55
55
|
end
|
56
56
|
|
57
|
-
it "
|
57
|
+
it "indexes specified blobs" do
|
58
58
|
repo = TestRepository.new
|
59
59
|
repo.index_blobs(
|
60
60
|
from_rev: '40f4a7a617393735a95a0bb67b08385bc1e7c66d',
|
@@ -62,7 +62,31 @@ describe TestRepository do
|
|
62
62
|
)
|
63
63
|
|
64
64
|
TestRepository.__elasticsearch__.refresh_index!
|
65
|
-
|
65
|
+
|
66
66
|
expect(repo.search('Permission is hereby granted', type: :blob)[:blobs][:total_count]).to eq(1)
|
67
67
|
end
|
68
|
+
|
69
|
+
it "applies repository_id filter for blobs" do
|
70
|
+
repo = TestRepository.new
|
71
|
+
repo.index_blobs
|
72
|
+
|
73
|
+
TestRepository.new("repo_second").index_blobs
|
74
|
+
|
75
|
+
TestRepository.__elasticsearch__.refresh_index!
|
76
|
+
|
77
|
+
expect(TestRepository.__elasticsearch__.search('def').results.count).to eq(8)
|
78
|
+
expect(repo.search('def')[:blobs][:total_count]).to eq(4)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "applies repository_id filter for commits" do
|
82
|
+
repo = TestRepository.new
|
83
|
+
repo.index_commits
|
84
|
+
|
85
|
+
TestRepository.new("repo_second").index_commits
|
86
|
+
|
87
|
+
TestRepository.__elasticsearch__.refresh_index!
|
88
|
+
|
89
|
+
expect(TestRepository.__elasticsearch__.search('test').results.count).to eq(4)
|
90
|
+
expect(repo.search('test')[:commits][:total_count]).to eq(2)
|
91
|
+
end
|
68
92
|
end
|
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.
|
4
|
+
version: 0.0.14
|
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-
|
13
|
+
date: 2016-05-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: elasticsearch-model
|