scalastic 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scalastic/partition.rb +12 -0
- data/lib/scalastic/version.rb +1 -1
- data/regression/regression_tests/document_create.rb +32 -0
- data/regression/regression_tests/mget.rb +32 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 658c178987891b8d35d5e53453957d166be292e8
|
4
|
+
data.tar.gz: c01b6636034a41ea44c2c02216d53d6c7fb801e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85c8a15a5b37793884bd143493ceea7d75bfebdb9afa16f4aa67c19b8d500d8a53863190c7050bd20907b42b5ff8cd994718c765d40f00c3fe2b4c732f2f6440
|
7
|
+
data.tar.gz: 3d87aebccf6648854df7f4ac582fe183432cba07723847665313bc8456180ac87bdae5a3ae06aabec9f6b5cd404b201e7e210cb0a6643104110cecd96e5b817d
|
data/lib/scalastic/partition.rb
CHANGED
@@ -42,6 +42,11 @@ module Scalastic
|
|
42
42
|
es_client.get(args)
|
43
43
|
end
|
44
44
|
|
45
|
+
def mget(args)
|
46
|
+
args = args.merge(index: config.search_endpoint(id))
|
47
|
+
es_client.mget(args)
|
48
|
+
end
|
49
|
+
|
45
50
|
def index(args)
|
46
51
|
args[:body] ||= {}
|
47
52
|
selector.apply_to(args[:body])
|
@@ -49,6 +54,13 @@ module Scalastic
|
|
49
54
|
es_client.index(args)
|
50
55
|
end
|
51
56
|
|
57
|
+
def create(args)
|
58
|
+
args[:body] ||= {}
|
59
|
+
selector.apply_to(args[:body])
|
60
|
+
args = args.merge(index: config.index_endpoint(id))
|
61
|
+
es_client.create(args)
|
62
|
+
end
|
63
|
+
|
52
64
|
def delete(args = {})
|
53
65
|
args = args.merge(index: config.search_endpoint(id))
|
54
66
|
es_client.delete(args)
|
data/lib/scalastic/version.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
module RegressionTests
|
2
|
+
module DocumentCreate
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def cleanup
|
6
|
+
client = Elasticsearch::Client.new
|
7
|
+
client.indices.delete(index: 'document_create') if client.indices.exists?(index: 'document_create')
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
client = Elasticsearch::Client.new
|
12
|
+
client.indices.create(index: 'document_create')
|
13
|
+
client.partitions.prepare_index(index: 'document_create')
|
14
|
+
|
15
|
+
partition = client.partitions.create(index: 'document_create', id: 1)
|
16
|
+
partition.create(type: 'test', id: 1, body: {subject: 'Test 1'})
|
17
|
+
partition.create(type: 'test', id: 2, body: {subject: 'Test 2'})
|
18
|
+
|
19
|
+
res = partition.create(type: 'test', id: 1, body: {subject: 'Test 1'}) rescue :failed
|
20
|
+
raise 'Indexing didn\'t fail' unless res == :failed
|
21
|
+
sleep(1.5)
|
22
|
+
|
23
|
+
hits = partition.search()['hits']['hits'].sort{|h1, h2| h1['_id'].to_i <=> h2['_id'].to_i}
|
24
|
+
expected_hits = [
|
25
|
+
{'_index' => 'document_create', '_type' => 'test', '_id' => '1', '_score' => 1.0, '_source' => {'subject' => 'Test 1', 'scalastic_partition_id' => 1}},
|
26
|
+
{'_index' => 'document_create', '_type' => 'test', '_id' => '2', '_score' => 1.0, '_source' => {'subject' => 'Test 2', 'scalastic_partition_id' => 1}},
|
27
|
+
]
|
28
|
+
|
29
|
+
raise "Expected: #{expected_hits}, got: #{hits}" unless expected_hits == hits
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RegressionTests
|
2
|
+
module Mget
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def cleanup
|
6
|
+
client = Elasticsearch::Client.new
|
7
|
+
client.indices.delete(index: 'mget') if client.indices.exists?(index: 'mget')
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
client = Elasticsearch::Client.new
|
12
|
+
client.indices.create index: 'mget'
|
13
|
+
client.partitions.prepare_index index: 'mget'
|
14
|
+
|
15
|
+
partition = client.partitions.create id: 1, index: 'mget'
|
16
|
+
partition.index id: 1, type: 'test', body: {subject: 'Test 1'}
|
17
|
+
partition.index id: 2, type: 'test', body: {subject: 'Test 2'}
|
18
|
+
|
19
|
+
expected_results = [
|
20
|
+
{'_index' => 'mget', '_type' => 'test', '_id' => '1', '_version' => 1, 'found' => true, '_source' => {'subject' => 'Test 1', 'scalastic_partition_id' => 1}},
|
21
|
+
{'_index' => 'mget', '_type' => 'test', '_id' => '2', '_version' => 1, 'found' => true, '_source' => {'subject' => 'Test 2', 'scalastic_partition_id' => 1}},
|
22
|
+
{'_index' => 'mget', '_type' => 'test', '_id' => '3', 'found' => false}
|
23
|
+
]
|
24
|
+
|
25
|
+
results = partition.mget(type: 'test', body: {ids: [1, 2, 3]})['docs']
|
26
|
+
raise "Expected: #{expected_results}, got: #{results}" unless expected_results == results
|
27
|
+
|
28
|
+
results = partition.mget(body: {docs: [{_type: 'test', _id: 1}, {_type: 'test', _id: 2}, {_type: 'test', _id: 3}]})['docs']
|
29
|
+
raise "Expected: #{expected_results}, got: #{results}" unless expected_results == results
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scalastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aliaksei Baturytski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -110,11 +110,13 @@ files:
|
|
110
110
|
- regression/regression_tests/custom_partition_prefix.rb
|
111
111
|
- regression/regression_tests/delete_by_query.rb
|
112
112
|
- regression/regression_tests/delete_partition.rb
|
113
|
+
- regression/regression_tests/document_create.rb
|
113
114
|
- regression/regression_tests/document_get.rb
|
114
115
|
- regression/regression_tests/endpoints.rb
|
115
116
|
- regression/regression_tests/extend_partition.rb
|
116
117
|
- regression/regression_tests/index_destinations.rb
|
117
118
|
- regression/regression_tests/list_partitions.rb
|
119
|
+
- regression/regression_tests/mget.rb
|
118
120
|
- regression/regression_tests/nested_selector.rb
|
119
121
|
- regression/regression_tests/nested_selector_bulk.rb
|
120
122
|
- regression/regression_tests/partition_operations.rb
|