elasticsearch-model 6.1.1 → 7.0.0.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/Gemfile +17 -0
  4. data/LICENSE.txt +199 -10
  5. data/README.md +17 -16
  6. data/Rakefile +18 -1
  7. data/elasticsearch-model.gemspec +19 -2
  8. data/examples/activerecord_article.rb +17 -0
  9. data/examples/activerecord_associations.rb +17 -0
  10. data/examples/activerecord_custom_analyzer.rb +17 -0
  11. data/examples/activerecord_mapping_completion.rb +17 -0
  12. data/examples/activerecord_mapping_edge_ngram.rb +17 -0
  13. data/examples/couchbase_article.rb +17 -0
  14. data/examples/datamapper_article.rb +17 -0
  15. data/examples/mongoid_article.rb +17 -0
  16. data/examples/ohm_article.rb +17 -0
  17. data/examples/riak_article.rb +17 -0
  18. data/gemfiles/3.0.gemfile +18 -1
  19. data/gemfiles/4.0.gemfile +20 -4
  20. data/gemfiles/5.0.gemfile +18 -1
  21. data/gemfiles/6.0.gemfile +21 -3
  22. data/lib/elasticsearch/model.rb +25 -15
  23. data/lib/elasticsearch/model/adapter.rb +17 -0
  24. data/lib/elasticsearch/model/adapters/active_record.rb +18 -1
  25. data/lib/elasticsearch/model/adapters/default.rb +17 -0
  26. data/lib/elasticsearch/model/adapters/mongoid.rb +17 -0
  27. data/lib/elasticsearch/model/adapters/multiple.rb +29 -4
  28. data/lib/elasticsearch/model/callbacks.rb +17 -0
  29. data/lib/elasticsearch/model/client.rb +17 -0
  30. data/lib/elasticsearch/model/ext/active_record.rb +17 -0
  31. data/lib/elasticsearch/model/hash_wrapper.rb +17 -0
  32. data/lib/elasticsearch/model/importing.rb +17 -0
  33. data/lib/elasticsearch/model/indexing.rb +29 -8
  34. data/lib/elasticsearch/model/multimodel.rb +17 -0
  35. data/lib/elasticsearch/model/naming.rb +19 -10
  36. data/lib/elasticsearch/model/proxy.rb +17 -0
  37. data/lib/elasticsearch/model/response.rb +17 -0
  38. data/lib/elasticsearch/model/response/aggregations.rb +17 -0
  39. data/lib/elasticsearch/model/response/base.rb +22 -1
  40. data/lib/elasticsearch/model/response/pagination.rb +17 -0
  41. data/lib/elasticsearch/model/response/pagination/kaminari.rb +17 -0
  42. data/lib/elasticsearch/model/response/pagination/will_paginate.rb +17 -0
  43. data/lib/elasticsearch/model/response/records.rb +17 -0
  44. data/lib/elasticsearch/model/response/result.rb +17 -0
  45. data/lib/elasticsearch/model/response/results.rb +17 -0
  46. data/lib/elasticsearch/model/response/suggestions.rb +17 -0
  47. data/lib/elasticsearch/model/searching.rb +17 -0
  48. data/lib/elasticsearch/model/serializing.rb +17 -0
  49. data/lib/elasticsearch/model/version.rb +18 -1
  50. data/spec/elasticsearch/model/adapter_spec.rb +17 -0
  51. data/spec/elasticsearch/model/adapters/active_record/associations_spec.rb +17 -0
  52. data/spec/elasticsearch/model/adapters/active_record/basic_spec.rb +281 -226
  53. data/spec/elasticsearch/model/adapters/active_record/dynamic_index_name_spec.rb +17 -0
  54. data/spec/elasticsearch/model/adapters/active_record/import_spec.rb +17 -0
  55. data/spec/elasticsearch/model/adapters/active_record/multi_model_spec.rb +17 -0
  56. data/spec/elasticsearch/model/adapters/active_record/namespaced_model_spec.rb +18 -1
  57. data/spec/elasticsearch/model/adapters/active_record/pagination_spec.rb +17 -0
  58. data/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb +18 -1
  59. data/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb +17 -0
  60. data/spec/elasticsearch/model/adapters/active_record_spec.rb +17 -0
  61. data/spec/elasticsearch/model/adapters/default_spec.rb +17 -0
  62. data/spec/elasticsearch/model/adapters/mongoid/basic_spec.rb +17 -0
  63. data/spec/elasticsearch/model/adapters/mongoid/multi_model_spec.rb +17 -0
  64. data/spec/elasticsearch/model/adapters/mongoid_spec.rb +17 -0
  65. data/spec/elasticsearch/model/adapters/multiple_spec.rb +17 -0
  66. data/spec/elasticsearch/model/callbacks_spec.rb +17 -0
  67. data/spec/elasticsearch/model/client_spec.rb +17 -0
  68. data/spec/elasticsearch/model/hash_wrapper_spec.rb +17 -0
  69. data/spec/elasticsearch/model/importing_spec.rb +17 -0
  70. data/spec/elasticsearch/model/indexing_spec.rb +108 -12
  71. data/spec/elasticsearch/model/module_spec.rb +17 -25
  72. data/spec/elasticsearch/model/multimodel_spec.rb +17 -0
  73. data/spec/elasticsearch/model/naming_inheritance_spec.rb +82 -143
  74. data/spec/elasticsearch/model/naming_spec.rb +22 -5
  75. data/spec/elasticsearch/model/proxy_spec.rb +17 -0
  76. data/spec/elasticsearch/model/response/aggregations_spec.rb +17 -0
  77. data/spec/elasticsearch/model/response/base_spec.rb +17 -0
  78. data/spec/elasticsearch/model/response/pagination/kaminari_spec.rb +85 -23
  79. data/spec/elasticsearch/model/response/pagination/will_paginate_spec.rb +17 -0
  80. data/spec/elasticsearch/model/response/records_spec.rb +17 -0
  81. data/spec/elasticsearch/model/response/response_spec.rb +17 -0
  82. data/spec/elasticsearch/model/response/result_spec.rb +17 -0
  83. data/spec/elasticsearch/model/response/results_spec.rb +17 -0
  84. data/spec/elasticsearch/model/searching_search_request_spec.rb +17 -0
  85. data/spec/elasticsearch/model/searching_spec.rb +17 -0
  86. data/spec/elasticsearch/model/serializing_spec.rb +17 -0
  87. data/spec/spec_helper.rb +18 -0
  88. data/spec/support/app.rb +18 -0
  89. data/spec/support/app/answer.rb +17 -0
  90. data/spec/support/app/article.rb +17 -0
  91. data/spec/support/app/article_for_pagination.rb +17 -0
  92. data/spec/support/app/article_no_type.rb +37 -0
  93. data/spec/support/app/article_with_custom_serialization.rb +17 -0
  94. data/spec/support/app/article_with_dynamic_index_name.rb +17 -0
  95. data/spec/support/app/author.rb +17 -0
  96. data/spec/support/app/authorship.rb +17 -0
  97. data/spec/support/app/category.rb +17 -0
  98. data/spec/support/app/comment.rb +17 -0
  99. data/spec/support/app/episode.rb +17 -0
  100. data/spec/support/app/image.rb +17 -0
  101. data/spec/support/app/import_article.rb +17 -0
  102. data/spec/support/app/mongoid_article.rb +17 -0
  103. data/spec/support/app/namespaced_book.rb +17 -0
  104. data/spec/support/app/parent_and_child_searchable.rb +21 -4
  105. data/spec/support/app/post.rb +17 -0
  106. data/spec/support/app/question.rb +17 -0
  107. data/spec/support/app/searchable.rb +17 -0
  108. data/spec/support/app/series.rb +17 -0
  109. metadata +12 -10
@@ -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 'ansi'
2
19
  require 'active_record'
3
20
  require 'elasticsearch/model'
@@ -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 'ansi'
2
19
  require 'sqlite3'
3
20
  require 'active_record'
@@ -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
  # Couchbase and Elasticsearch
2
19
  # ===========================
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
  # DataMapper and Elasticsearch
2
19
  # ============================
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
  # Mongoid and Elasticsearch
2
19
  # =========================
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
  # Ohm for Redis and Elasticsearch
2
19
  # ===============================
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
  # Riak and Elasticsearch
2
19
  # ======================
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
  # Usage:
2
19
  #
3
20
  # $ BUNDLE_GEMFILE=./gemfiles/3.0.gemfile bundle install
@@ -10,7 +27,7 @@ gemspec path: '../'
10
27
  gem 'activemodel', '>= 3.0'
11
28
  gem 'activerecord', '~> 3.2'
12
29
  gem 'mongoid', '>= 3.0'
13
- gem 'sqlite3', '~> 1.3.6' unless defined?(JRUBY_VERSION)
30
+ gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION)
14
31
 
15
32
  group :development, :testing do
16
33
  gem 'rspec'
@@ -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
  # Usage:
2
19
  #
3
20
  # $ BUNDLE_GEMFILE=./gemfiles/4.0.gemfile bundle install
@@ -9,11 +26,10 @@ gemspec path: '../'
9
26
 
10
27
  gem 'activemodel', '~> 4'
11
28
  gem 'activerecord', '~> 4'
29
+ gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION)
12
30
  gem 'mongoid', '~> 5'
13
- gem 'sqlite3', '~> 1.3.6' unless defined?(JRUBY_VERSION)
14
31
 
15
32
  group :development, :testing do
16
- gem 'bigdecimal', '~> 1'
17
- gem 'pry-nav'
18
33
  gem 'rspec'
19
- end
34
+ gem 'pry-nav'
35
+ 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
  # Usage:
2
19
  #
3
20
  # $ BUNDLE_GEMFILE=./gemfiles/5.0.gemfile bundle install
@@ -10,7 +27,7 @@ gemspec path: '../'
10
27
  gem 'activemodel', '~> 5'
11
28
  gem 'activerecord', '~> 5'
12
29
  gem 'sqlite3' unless defined?(JRUBY_VERSION)
13
- gem 'mongoid', '~> 6.4'
30
+ gem 'mongoid', '~> 6'
14
31
 
15
32
  group :development, :testing do
16
33
  gem 'rspec'
@@ -1,16 +1,34 @@
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
  # Usage:
2
19
  #
3
20
  # $ BUNDLE_GEMFILE=./gemfiles/6.0.gemfile bundle install
4
21
  # $ BUNDLE_GEMFILE=./gemfiles/6.0.gemfile bundle exec rake test:integration
5
22
 
23
+
6
24
  source 'https://rubygems.org'
7
25
 
8
26
  gemspec path: '../'
9
27
 
10
- gem 'activemodel', '~> 6'
11
- gem 'activerecord', '~> 6'
28
+ gem 'activemodel', '6.0.0.rc1'
29
+ gem 'activerecord', '6.0.0.rc1'
12
30
  gem 'sqlite3' unless defined?(JRUBY_VERSION)
13
- gem 'mongoid', '~> 7'
31
+ gem 'mongoid', '~> 6'
14
32
 
15
33
  group :development, :testing do
16
34
  gem 'rspec'
@@ -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 'hashie/mash'
2
19
 
3
20
  require 'active_support/core_ext/module/delegation'
@@ -131,6 +148,12 @@ module Elasticsearch
131
148
  end
132
149
  end
133
150
 
151
+ # Access the module settings
152
+ #
153
+ def self.settings
154
+ @settings ||= {}
155
+ end
156
+
134
157
  module ClassMethods
135
158
  # Get the client common for all models
136
159
  #
@@ -187,7 +210,7 @@ module Elasticsearch
187
210
  # @note Inheritance is disabled by default.
188
211
  #
189
212
  def inheritance_enabled
190
- @settings[:inheritance_enabled] ||= false
213
+ @inheritance_enabled ||= false
191
214
  end
192
215
 
193
216
  # Enable inheritance of index_name and document_type
@@ -197,21 +220,8 @@ module Elasticsearch
197
220
  # Elasticsearch::Model.inheritance_enabled = true
198
221
  #
199
222
  def inheritance_enabled=(inheritance_enabled)
200
- warn STI_DEPRECATION_WARNING if inheritance_enabled
201
- @settings[:inheritance_enabled] = inheritance_enabled
223
+ @inheritance_enabled = inheritance_enabled
202
224
  end
203
-
204
- # Access the module settings
205
- #
206
- def settings
207
- @settings ||= {}
208
- end
209
-
210
- private
211
-
212
- STI_DEPRECATION_WARNING = "DEPRECATION WARNING: Support for Single Table Inheritance (STI) is deprecated " +
213
- "and will be removed in version 7.0.0.\nPlease save different model documents in separate indices and refer " +
214
- "to the Elasticsearch documentation for more information.".freeze
215
225
  end
216
226
  extend ClassMethods
217
227
 
@@ -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
  module Elasticsearch
2
19
  module Model
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
  module Elasticsearch
2
19
  module Model
3
20
  module Adapter
@@ -85,7 +102,7 @@ module Elasticsearch
85
102
  scope = scope.__send__(named_scope) if named_scope
86
103
  scope = scope.instance_exec(&query) if query
87
104
 
88
- scope.find_in_batches(**options) do |batch|
105
+ scope.find_in_batches(options) do |batch|
89
106
  batch = self.__send__(preprocess, batch) if preprocess
90
107
  yield(batch) if batch.present?
91
108
  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
  module Elasticsearch
2
19
  module Model
3
20
  module Adapter
@@ -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
  module Elasticsearch
2
19
  module Model
3
20
  module Adapter
@@ -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
  module Elasticsearch
2
19
  module Model
3
20
  module Adapter
@@ -58,8 +75,8 @@ module Elasticsearch
58
75
  klass.where(klass.primary_key => ids)
59
76
  when Elasticsearch::Model::Adapter::Mongoid.equal?(adapter)
60
77
  klass.where(:id.in => ids)
61
- else
62
- klass.find(ids)
78
+ else
79
+ klass.find(ids)
63
80
  end
64
81
  end
65
82
 
@@ -91,13 +108,21 @@ module Elasticsearch
91
108
  def __type_for_hit(hit)
92
109
  @@__types ||= {}
93
110
 
94
- @@__types[ "#{hit[:_index]}::#{hit[:_type]}" ] ||= begin
111
+ key = "#{hit[:_index]}::#{hit[:_type]}" if hit[:_type] && hit[:_type] != '_doc'
112
+ key = hit[:_index] unless key
113
+
114
+ @@__types[key] ||= begin
95
115
  Registry.all.detect do |model|
96
- model.index_name == hit[:_index] && model.document_type == hit[:_type]
116
+ (model.index_name == hit[:_index] && __no_type?(hit)) ||
117
+ (model.index_name == hit[:_index] && model.document_type == hit[:_type])
97
118
  end
98
119
  end
99
120
  end
100
121
 
122
+ def __no_type?(hit)
123
+ hit[:_type].nil? || hit[:_type] == '_doc'
124
+ end
125
+
101
126
  # Returns the adapter registered for a particular `klass` or `nil` if not available
102
127
  #
103
128
  # @api private