elasticsearch-model 6.1.2 → 7.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/Gemfile +17 -0
- data/LICENSE.txt +199 -10
- data/README.md +17 -16
- data/Rakefile +21 -6
- data/elasticsearch-model.gemspec +19 -2
- data/examples/activerecord_article.rb +17 -0
- data/examples/activerecord_associations.rb +17 -0
- data/examples/activerecord_custom_analyzer.rb +17 -0
- data/examples/activerecord_mapping_completion.rb +17 -0
- data/examples/activerecord_mapping_edge_ngram.rb +17 -0
- data/examples/couchbase_article.rb +17 -0
- data/examples/datamapper_article.rb +17 -0
- data/examples/mongoid_article.rb +17 -0
- data/examples/ohm_article.rb +17 -0
- data/examples/riak_article.rb +17 -0
- data/gemfiles/3.0.gemfile +18 -1
- data/gemfiles/4.0.gemfile +20 -4
- data/gemfiles/5.0.gemfile +18 -1
- data/gemfiles/6.0.gemfile +21 -3
- data/lib/elasticsearch/model/adapter.rb +17 -0
- data/lib/elasticsearch/model/adapters/active_record.rb +18 -1
- data/lib/elasticsearch/model/adapters/default.rb +17 -0
- data/lib/elasticsearch/model/adapters/mongoid.rb +17 -0
- data/lib/elasticsearch/model/adapters/multiple.rb +29 -4
- data/lib/elasticsearch/model/callbacks.rb +17 -0
- data/lib/elasticsearch/model/client.rb +17 -0
- data/lib/elasticsearch/model/ext/active_record.rb +17 -0
- data/lib/elasticsearch/model/hash_wrapper.rb +17 -0
- data/lib/elasticsearch/model/importing.rb +17 -0
- data/lib/elasticsearch/model/indexing.rb +29 -8
- data/lib/elasticsearch/model/multimodel.rb +17 -0
- data/lib/elasticsearch/model/naming.rb +19 -10
- data/lib/elasticsearch/model/proxy.rb +17 -0
- data/lib/elasticsearch/model/response/aggregations.rb +17 -0
- data/lib/elasticsearch/model/response/base.rb +22 -1
- data/lib/elasticsearch/model/response/pagination/kaminari.rb +17 -0
- data/lib/elasticsearch/model/response/pagination/will_paginate.rb +17 -0
- data/lib/elasticsearch/model/response/pagination.rb +17 -0
- data/lib/elasticsearch/model/response/records.rb +17 -0
- data/lib/elasticsearch/model/response/result.rb +17 -0
- data/lib/elasticsearch/model/response/results.rb +17 -0
- data/lib/elasticsearch/model/response/suggestions.rb +17 -0
- data/lib/elasticsearch/model/response.rb +17 -0
- data/lib/elasticsearch/model/searching.rb +17 -0
- data/lib/elasticsearch/model/serializing.rb +17 -0
- data/lib/elasticsearch/model/version.rb +18 -1
- data/lib/elasticsearch/model.rb +25 -15
- data/spec/elasticsearch/model/adapter_spec.rb +17 -0
- data/spec/elasticsearch/model/adapters/active_record/associations_spec.rb +17 -0
- data/spec/elasticsearch/model/adapters/active_record/basic_spec.rb +281 -226
- data/spec/elasticsearch/model/adapters/active_record/dynamic_index_name_spec.rb +17 -0
- data/spec/elasticsearch/model/adapters/active_record/import_spec.rb +17 -0
- data/spec/elasticsearch/model/adapters/active_record/multi_model_spec.rb +17 -0
- data/spec/elasticsearch/model/adapters/active_record/namespaced_model_spec.rb +18 -1
- data/spec/elasticsearch/model/adapters/active_record/pagination_spec.rb +17 -0
- data/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb +18 -1
- data/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb +18 -2
- data/spec/elasticsearch/model/adapters/active_record_spec.rb +17 -0
- data/spec/elasticsearch/model/adapters/default_spec.rb +17 -0
- data/spec/elasticsearch/model/adapters/mongoid/basic_spec.rb +17 -0
- data/spec/elasticsearch/model/adapters/mongoid/multi_model_spec.rb +17 -0
- data/spec/elasticsearch/model/adapters/mongoid_spec.rb +17 -0
- data/spec/elasticsearch/model/adapters/multiple_spec.rb +17 -0
- data/spec/elasticsearch/model/callbacks_spec.rb +17 -0
- data/spec/elasticsearch/model/client_spec.rb +17 -0
- data/spec/elasticsearch/model/hash_wrapper_spec.rb +17 -0
- data/spec/elasticsearch/model/importing_spec.rb +17 -0
- data/spec/elasticsearch/model/indexing_spec.rb +108 -12
- data/spec/elasticsearch/model/module_spec.rb +17 -25
- data/spec/elasticsearch/model/multimodel_spec.rb +17 -0
- data/spec/elasticsearch/model/naming_inheritance_spec.rb +82 -143
- data/spec/elasticsearch/model/naming_spec.rb +22 -5
- data/spec/elasticsearch/model/proxy_spec.rb +17 -0
- data/spec/elasticsearch/model/response/aggregations_spec.rb +17 -0
- data/spec/elasticsearch/model/response/base_spec.rb +17 -0
- data/spec/elasticsearch/model/response/pagination/kaminari_spec.rb +85 -23
- data/spec/elasticsearch/model/response/pagination/will_paginate_spec.rb +17 -0
- data/spec/elasticsearch/model/response/records_spec.rb +17 -0
- data/spec/elasticsearch/model/response/response_spec.rb +17 -0
- data/spec/elasticsearch/model/response/result_spec.rb +17 -0
- data/spec/elasticsearch/model/response/results_spec.rb +17 -0
- data/spec/elasticsearch/model/searching_search_request_spec.rb +17 -0
- data/spec/elasticsearch/model/searching_spec.rb +17 -0
- data/spec/elasticsearch/model/serializing_spec.rb +17 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/app/answer.rb +17 -0
- data/spec/support/app/article.rb +17 -0
- data/spec/support/app/article_for_pagination.rb +17 -0
- data/spec/support/app/article_no_type.rb +37 -0
- data/spec/support/app/article_with_custom_serialization.rb +17 -0
- data/spec/support/app/article_with_dynamic_index_name.rb +17 -0
- data/spec/support/app/author.rb +17 -0
- data/spec/support/app/authorship.rb +17 -0
- data/spec/support/app/category.rb +17 -0
- data/spec/support/app/comment.rb +17 -0
- data/spec/support/app/episode.rb +17 -0
- data/spec/support/app/image.rb +17 -0
- data/spec/support/app/import_article.rb +17 -0
- data/spec/support/app/mongoid_article.rb +17 -0
- data/spec/support/app/namespaced_book.rb +17 -0
- data/spec/support/app/parent_and_child_searchable.rb +21 -4
- data/spec/support/app/post.rb +17 -0
- data/spec/support/app/question.rb +17 -0
- data/spec/support/app/searchable.rb +17 -0
- data/spec/support/app/series.rb +17 -0
- data/spec/support/app.rb +18 -0
- metadata +12 -10
@@ -1,184 +1,123 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'spec_helper'
|
2
19
|
|
3
20
|
describe 'naming inheritance' do
|
4
21
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
extend ActiveModel::Naming
|
9
|
-
|
10
|
-
extend Elasticsearch::Model::Naming::ClassMethods
|
11
|
-
include Elasticsearch::Model::Naming::InstanceMethods
|
12
|
-
end
|
13
|
-
|
14
|
-
Animal = Class.new TestBase do
|
15
|
-
extend ActiveModel::Naming
|
16
|
-
|
17
|
-
extend Elasticsearch::Model::Naming::ClassMethods
|
18
|
-
include Elasticsearch::Model::Naming::InstanceMethods
|
19
|
-
|
20
|
-
index_name "mammals"
|
21
|
-
document_type "mammal"
|
22
|
-
end
|
23
|
-
|
24
|
-
Dog = Class.new Animal
|
25
|
-
|
26
|
-
module ::MyNamespace
|
27
|
-
Dog = Class.new Animal
|
28
|
-
end
|
29
|
-
|
30
|
-
Cat = Class.new Animal do
|
31
|
-
extend ActiveModel::Naming
|
22
|
+
before(:all) do
|
23
|
+
class ::TestBase
|
24
|
+
extend ActiveModel::Naming
|
32
25
|
|
33
|
-
|
34
|
-
|
26
|
+
extend Elasticsearch::Model::Naming::ClassMethods
|
27
|
+
include Elasticsearch::Model::Naming::InstanceMethods
|
28
|
+
end
|
35
29
|
|
36
|
-
|
37
|
-
|
38
|
-
end
|
30
|
+
class ::Animal < ::TestBase
|
31
|
+
extend ActiveModel::Naming
|
39
32
|
|
40
|
-
|
33
|
+
extend Elasticsearch::Model::Naming::ClassMethods
|
34
|
+
include Elasticsearch::Model::Naming::InstanceMethods
|
41
35
|
|
42
|
-
|
43
|
-
|
36
|
+
index_name "mammals"
|
37
|
+
document_type "mammal"
|
44
38
|
end
|
45
39
|
|
46
|
-
|
47
|
-
original_value = Elasticsearch::Model.inheritance_enabled
|
48
|
-
Elasticsearch::Model.inheritance_enabled = true
|
49
|
-
example.run
|
50
|
-
Elasticsearch::Model.inheritance_enabled = original_value
|
40
|
+
class ::Dog < ::Animal
|
51
41
|
end
|
52
42
|
|
53
|
-
|
54
|
-
|
55
|
-
it 'returns the default index name' do
|
56
|
-
expect(TestBase.index_name).to eq('test_bases')
|
57
|
-
expect(TestBase.new.index_name).to eq('test_bases')
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'returns the explicit index name' do
|
61
|
-
expect(Animal.index_name).to eq('mammals')
|
62
|
-
expect(Animal.new.index_name).to eq('mammals')
|
63
|
-
|
64
|
-
expect(Cat.index_name).to eq('cats')
|
65
|
-
expect(Cat.new.index_name).to eq('cats')
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'returns the ancestor index name' do
|
69
|
-
expect(Dog.index_name).to eq('mammals')
|
70
|
-
expect(Dog.new.index_name).to eq('mammals')
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'returns the ancestor index name for namespaced models' do
|
74
|
-
expect(::MyNamespace::Dog.index_name).to eq('mammals')
|
75
|
-
expect(::MyNamespace::Dog.new.index_name).to eq('mammals')
|
43
|
+
module ::MyNamespace
|
44
|
+
class Dog < ::Animal
|
76
45
|
end
|
77
46
|
end
|
78
47
|
|
79
|
-
|
80
|
-
|
81
|
-
it 'returns nil' do
|
82
|
-
expect(TestBase.document_type).to eq('_doc')
|
83
|
-
expect(TestBase.new.document_type).to eq('_doc')
|
84
|
-
end
|
48
|
+
class ::Cat < ::Animal
|
49
|
+
extend ActiveModel::Naming
|
85
50
|
|
86
|
-
|
87
|
-
|
88
|
-
expect(Animal.new.document_type).to eq('mammal')
|
51
|
+
extend Elasticsearch::Model::Naming::ClassMethods
|
52
|
+
include Elasticsearch::Model::Naming::InstanceMethods
|
89
53
|
|
90
|
-
|
91
|
-
|
92
|
-
|
54
|
+
index_name "cats"
|
55
|
+
document_type "cat"
|
56
|
+
end
|
93
57
|
|
94
|
-
|
95
|
-
expect(Dog.document_type).to eq('mammal')
|
96
|
-
expect(Dog.new.document_type).to eq('mammal')
|
97
|
-
end
|
58
|
+
end
|
98
59
|
|
99
|
-
|
100
|
-
|
101
|
-
expect(::MyNamespace::Dog.new.document_type).to eq('mammal')
|
102
|
-
end
|
103
|
-
end
|
60
|
+
after(:all) do
|
61
|
+
remove_classes(TestBase, Animal, MyNamespace, Cat)
|
104
62
|
end
|
105
63
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
64
|
+
around(:all) do |example|
|
65
|
+
original_value = Elasticsearch::Model.settings[:inheritance_enabled]
|
66
|
+
Elasticsearch::Model.settings[:inheritance_enabled] = true
|
67
|
+
example.run
|
68
|
+
Elasticsearch::Model.settings[:inheritance_enabled] = original_value
|
69
|
+
end
|
110
70
|
|
111
|
-
include Elasticsearch::Model
|
112
|
-
end
|
113
71
|
|
114
|
-
|
115
|
-
index_name "mammals"
|
116
|
-
document_type "mammal"
|
117
|
-
end
|
72
|
+
describe '#index_name' do
|
118
73
|
|
119
|
-
|
74
|
+
it 'returns the default index name' do
|
75
|
+
expect(TestBase.index_name).to eq('test_bases')
|
76
|
+
expect(TestBase.new.index_name).to eq('test_bases')
|
77
|
+
end
|
120
78
|
|
121
|
-
|
122
|
-
|
123
|
-
|
79
|
+
it 'returns the explicit index name' do
|
80
|
+
expect(Animal.index_name).to eq('mammals')
|
81
|
+
expect(Animal.new.index_name).to eq('mammals')
|
124
82
|
|
125
|
-
Cat
|
126
|
-
|
127
|
-
document_type "cat"
|
128
|
-
end
|
83
|
+
expect(Cat.index_name).to eq('cats')
|
84
|
+
expect(Cat.new.index_name).to eq('cats')
|
129
85
|
end
|
130
86
|
|
131
|
-
|
132
|
-
|
87
|
+
it 'returns the ancestor index name' do
|
88
|
+
expect(Dog.index_name).to eq('mammals')
|
89
|
+
expect(Dog.new.index_name).to eq('mammals')
|
133
90
|
end
|
134
91
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
example.run
|
139
|
-
Elasticsearch::Model.settings[:inheritance_enabled] = original_value
|
92
|
+
it 'returns the ancestor index name for namespaced models' do
|
93
|
+
expect(::MyNamespace::Dog.index_name).to eq('mammals')
|
94
|
+
expect(::MyNamespace::Dog.new.index_name).to eq('mammals')
|
140
95
|
end
|
96
|
+
end
|
141
97
|
|
142
|
-
|
143
|
-
|
144
|
-
it 'returns the default index name' do
|
145
|
-
expect(TestBase.index_name).to eq('test_bases')
|
146
|
-
end
|
147
|
-
|
148
|
-
it 'returns the explicit index name' do
|
149
|
-
expect(Animal.index_name).to eq('mammals')
|
150
|
-
|
151
|
-
expect(Cat.index_name).to eq('cats')
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'returns the ancestor index name' do
|
155
|
-
expect(Dog.index_name).to eq('mammals')
|
156
|
-
end
|
98
|
+
describe '#document_type' do
|
157
99
|
|
158
|
-
|
159
|
-
|
160
|
-
|
100
|
+
it 'returns nil' do
|
101
|
+
expect(TestBase.document_type).to be_nil
|
102
|
+
expect(TestBase.new.document_type).to be_nil
|
161
103
|
end
|
162
104
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
expect(TestBase.document_type).to eq('_doc')
|
167
|
-
end
|
105
|
+
it 'returns the explicit document type' do
|
106
|
+
expect(Animal.document_type).to eq('mammal')
|
107
|
+
expect(Animal.new.document_type).to eq('mammal')
|
168
108
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
expect(Cat.document_type).to eq('cat')
|
173
|
-
end
|
109
|
+
expect(Cat.document_type).to eq('cat')
|
110
|
+
expect(Cat.new.document_type).to eq('cat')
|
111
|
+
end
|
174
112
|
|
175
|
-
|
176
|
-
|
177
|
-
|
113
|
+
it 'returns the ancestor document type' do
|
114
|
+
expect(Dog.document_type).to eq('mammal')
|
115
|
+
expect(Dog.new.document_type).to eq('mammal')
|
116
|
+
end
|
178
117
|
|
179
|
-
|
180
|
-
|
181
|
-
|
118
|
+
it 'returns the ancestor document type for namespaced models' do
|
119
|
+
expect(::MyNamespace::Dog.document_type).to eq('mammal')
|
120
|
+
expect(::MyNamespace::Dog.new.document_type).to eq('mammal')
|
182
121
|
end
|
183
122
|
end
|
184
123
|
end
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'spec_helper'
|
2
19
|
|
3
20
|
describe 'naming' do
|
@@ -34,9 +51,9 @@ describe 'naming' do
|
|
34
51
|
expect(::MyNamespace::DummyNamingModelInNamespace.new.index_name).to eq('my_namespace-dummy_naming_model_in_namespaces')
|
35
52
|
end
|
36
53
|
|
37
|
-
it 'returns
|
38
|
-
expect(DummyNamingModel.document_type).to
|
39
|
-
expect(DummyNamingModel.new.document_type).to
|
54
|
+
it 'returns nil' do
|
55
|
+
expect(DummyNamingModel.document_type).to be_nil
|
56
|
+
expect(DummyNamingModel.new.document_type).to be_nil
|
40
57
|
end
|
41
58
|
|
42
59
|
describe '#index_name' do
|
@@ -124,8 +141,8 @@ describe 'naming' do
|
|
124
141
|
|
125
142
|
describe '#document_type' do
|
126
143
|
|
127
|
-
it 'returns
|
128
|
-
expect(DummyNamingModel.document_type).to
|
144
|
+
it 'returns nil' do
|
145
|
+
expect(DummyNamingModel.document_type).to be_nil
|
129
146
|
end
|
130
147
|
|
131
148
|
context 'when the method is called with an argument' do
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'spec_helper'
|
2
19
|
|
3
20
|
describe Elasticsearch::Model::Proxy do
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'spec_helper'
|
2
19
|
|
3
20
|
describe Elasticsearch::Model::Response::Aggregations do
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'spec_helper'
|
2
19
|
|
3
20
|
describe Elasticsearch::Model::Response::Base do
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'spec_helper'
|
2
19
|
|
3
20
|
describe 'Elasticsearch::Model::Response::Response Kaminari' do
|
@@ -14,11 +31,6 @@ describe 'Elasticsearch::Model::Response::Response Kaminari' do
|
|
14
31
|
remove_classes(ModelClass)
|
15
32
|
end
|
16
33
|
|
17
|
-
let(:response_document) do
|
18
|
-
{ 'took' => '5', 'timed_out' => false, '_shards' => {'one' => 'OK'},
|
19
|
-
'hits' => { 'total' => 100, 'hits' => (1..100).to_a.map { |i| { _id: i } } } }
|
20
|
-
end
|
21
|
-
|
22
34
|
let(:search) do
|
23
35
|
Elasticsearch::Model::Searching::SearchRequest.new(model, '*')
|
24
36
|
end
|
@@ -374,37 +386,87 @@ describe 'Elasticsearch::Model::Response::Response Kaminari' do
|
|
374
386
|
end
|
375
387
|
end
|
376
388
|
|
377
|
-
context 'when
|
389
|
+
context 'when Elasticsearch version is < 7.0' do
|
378
390
|
|
379
|
-
let(:
|
380
|
-
|
391
|
+
let(:response_document) do
|
392
|
+
{ 'took' => '5', 'timed_out' => false, '_shards' => {'one' => 'OK'},
|
393
|
+
'hits' => { 'total' => 100, 'hits' => (1..100).to_a.map { |i| { _id: i } } } }
|
381
394
|
end
|
382
395
|
|
383
|
-
|
384
|
-
'bar'
|
385
|
-
end
|
396
|
+
context 'when the model is a single one' do
|
386
397
|
|
387
|
-
|
388
|
-
|
398
|
+
let(:model) do
|
399
|
+
ModelClass
|
400
|
+
end
|
401
|
+
|
402
|
+
let(:type_field) do
|
403
|
+
'bar'
|
404
|
+
end
|
405
|
+
|
406
|
+
let(:index_field) do
|
407
|
+
'foo'
|
408
|
+
end
|
409
|
+
|
410
|
+
it_behaves_like 'a search request that can be paginated'
|
389
411
|
end
|
390
412
|
|
391
|
-
|
392
|
-
|
413
|
+
context 'when the model is a multimodel' do
|
414
|
+
|
415
|
+
let(:model) do
|
416
|
+
Elasticsearch::Model::Multimodel.new(ModelClass)
|
417
|
+
end
|
393
418
|
|
394
|
-
|
419
|
+
let(:type_field) do
|
420
|
+
['bar']
|
421
|
+
end
|
422
|
+
|
423
|
+
let(:index_field) do
|
424
|
+
['foo']
|
425
|
+
end
|
395
426
|
|
396
|
-
|
397
|
-
Elasticsearch::Model::Multimodel.new(ModelClass)
|
427
|
+
it_behaves_like 'a search request that can be paginated'
|
398
428
|
end
|
429
|
+
end
|
399
430
|
|
400
|
-
|
401
|
-
|
431
|
+
context 'when Elasticsearch version is >= 7.0' do
|
432
|
+
|
433
|
+
let(:response_document) do
|
434
|
+
{ 'took' => '5', 'timed_out' => false, '_shards' => {'one' => 'OK'},
|
435
|
+
'hits' => { 'total' => { 'value' => 100, 'relation' => 'eq' }, 'hits' => (1..100).to_a.map { |i| { _id: i } } } }
|
402
436
|
end
|
403
437
|
|
404
|
-
|
405
|
-
|
438
|
+
context 'when the model is a single one' do
|
439
|
+
|
440
|
+
let(:model) do
|
441
|
+
ModelClass
|
442
|
+
end
|
443
|
+
|
444
|
+
let(:type_field) do
|
445
|
+
'bar'
|
446
|
+
end
|
447
|
+
|
448
|
+
let(:index_field) do
|
449
|
+
'foo'
|
450
|
+
end
|
451
|
+
|
452
|
+
it_behaves_like 'a search request that can be paginated'
|
406
453
|
end
|
407
454
|
|
408
|
-
|
455
|
+
context 'when the model is a multimodel' do
|
456
|
+
|
457
|
+
let(:model) do
|
458
|
+
Elasticsearch::Model::Multimodel.new(ModelClass)
|
459
|
+
end
|
460
|
+
|
461
|
+
let(:type_field) do
|
462
|
+
['bar']
|
463
|
+
end
|
464
|
+
|
465
|
+
let(:index_field) do
|
466
|
+
['foo']
|
467
|
+
end
|
468
|
+
|
469
|
+
it_behaves_like 'a search request that can be paginated'
|
470
|
+
end
|
409
471
|
end
|
410
472
|
end
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'spec_helper'
|
2
19
|
|
3
20
|
describe 'Elasticsearch::Model::Response::Response WillPaginate' do
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'spec_helper'
|
2
19
|
|
3
20
|
describe Elasticsearch::Model::Response::Records do
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'spec_helper'
|
2
19
|
|
3
20
|
describe Elasticsearch::Model::Response::Response do
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'spec_helper'
|
2
19
|
require 'active_support/json/encoding'
|
3
20
|
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'spec_helper'
|
2
19
|
|
3
20
|
describe Elasticsearch::Model::Response::Results do
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'spec_helper'
|
2
19
|
|
3
20
|
describe Elasticsearch::Model::Serializing do
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'spec_helper'
|
2
19
|
|
3
20
|
describe Elasticsearch::Model::Searching::ClassMethods do
|