elasticsearch-model 6.1.0 → 7.0.0
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.
- checksums.yaml +4 -4
- data/.gitignore +3 -3
- data/Gemfile +17 -0
- data/LICENSE.txt +199 -10
- data/README.md +36 -25
- data/Rakefile +18 -1
- data/elasticsearch-model.gemspec +17 -0
- data/examples/activerecord_article.rb +17 -0
- data/examples/activerecord_associations.rb +33 -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 +18 -1
- data/gemfiles/5.0.gemfile +17 -0
- data/gemfiles/6.0.gemfile +36 -0
- data/lib/elasticsearch/model/adapter.rb +17 -0
- data/lib/elasticsearch/model/adapters/active_record.rb +17 -0
- 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 +50 -12
- data/lib/elasticsearch/model/indexing.rb +69 -43
- data/lib/elasticsearch/model/multimodel.rb +17 -0
- data/lib/elasticsearch/model/naming.rb +19 -19
- data/lib/elasticsearch/model/proxy.rb +58 -21
- 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 -1
- 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 +26 -61
- 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 +17 -0
- 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 +111 -15
- data/spec/elasticsearch/model/module_spec.rb +17 -25
- data/spec/elasticsearch/model/multimodel_spec.rb +17 -0
- 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 +27 -3
- 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 +27 -2
- metadata +6 -5
- data/spec/elasticsearch/model/naming_inheritance_spec.rb +0 -184
|
@@ -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
|
class Category < ActiveRecord::Base
|
|
2
19
|
has_and_belongs_to_many :posts
|
|
3
20
|
end
|
data/spec/support/app/comment.rb
CHANGED
|
@@ -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
|
class Comment < ActiveRecord::Base
|
|
2
19
|
belongs_to :post, touch: true
|
|
3
20
|
end
|
data/spec/support/app/episode.rb
CHANGED
|
@@ -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
|
class Episode < ActiveRecord::Base
|
|
2
19
|
include Elasticsearch::Model
|
|
3
20
|
include Elasticsearch::Model::Callbacks
|
data/spec/support/app/image.rb
CHANGED
|
@@ -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
|
class Image
|
|
2
19
|
include Mongoid::Document
|
|
3
20
|
include 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
|
class ImportArticle < ActiveRecord::Base
|
|
2
19
|
include Elasticsearch::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
|
class ::MongoidArticle
|
|
2
19
|
include Mongoid::Document
|
|
3
20
|
include 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
|
module MyNamespace
|
|
2
19
|
class Book < ActiveRecord::Base
|
|
3
20
|
include Elasticsearch::Model
|
|
@@ -1,10 +1,27 @@
|
|
|
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 ParentChildSearchable
|
|
2
19
|
INDEX_NAME = 'questions_and_answers'.freeze
|
|
3
20
|
JOIN = 'join'.freeze
|
|
4
21
|
|
|
5
22
|
def create_index!(options={})
|
|
6
23
|
client = Question.__elasticsearch__.client
|
|
7
|
-
client.indices.delete index: INDEX_NAME rescue nil if options
|
|
24
|
+
client.indices.delete index: INDEX_NAME rescue nil if options.delete(:force)
|
|
8
25
|
|
|
9
26
|
settings = Question.settings.to_hash.merge Answer.settings.to_hash
|
|
10
27
|
mapping_properties = { join_field: { type: JOIN,
|
|
@@ -14,10 +31,10 @@ module ParentChildSearchable
|
|
|
14
31
|
Answer.mappings.to_hash[:doc][:properties])
|
|
15
32
|
mappings = { doc: { properties: merged_properties }}
|
|
16
33
|
|
|
17
|
-
client.indices.create index: INDEX_NAME,
|
|
18
|
-
|
|
34
|
+
client.indices.create({ index: INDEX_NAME,
|
|
35
|
+
body: {
|
|
19
36
|
settings: settings.to_hash,
|
|
20
|
-
mappings: mappings }
|
|
37
|
+
mappings: mappings } }.merge(options))
|
|
21
38
|
end
|
|
22
39
|
|
|
23
40
|
extend self
|
data/spec/support/app/post.rb
CHANGED
|
@@ -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
|
class Post < ActiveRecord::Base
|
|
2
19
|
include Searchable
|
|
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
|
class Question < ActiveRecord::Base
|
|
2
19
|
include Elasticsearch::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 Searchable
|
|
2
19
|
extend ActiveSupport::Concern
|
|
3
20
|
|
data/spec/support/app/series.rb
CHANGED
|
@@ -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
|
class Series < ActiveRecord::Base
|
|
2
19
|
include Elasticsearch::Model
|
|
3
20
|
include Elasticsearch::Model::Callbacks
|
data/spec/support/app.rb
CHANGED
|
@@ -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 'active_record'
|
|
2
19
|
|
|
3
20
|
require 'support/app/question'
|
|
@@ -9,13 +26,21 @@ require 'support/app/namespaced_book'
|
|
|
9
26
|
require 'support/app/article_for_pagination'
|
|
10
27
|
require 'support/app/article_with_dynamic_index_name'
|
|
11
28
|
require 'support/app/episode'
|
|
12
|
-
require 'support/app/image'
|
|
13
29
|
require 'support/app/series'
|
|
14
|
-
require 'support/app/mongoid_article'
|
|
15
30
|
require 'support/app/article'
|
|
31
|
+
require 'support/app/article_no_type'
|
|
16
32
|
require 'support/app/searchable'
|
|
17
33
|
require 'support/app/category'
|
|
18
34
|
require 'support/app/author'
|
|
19
35
|
require 'support/app/authorship'
|
|
20
36
|
require 'support/app/comment'
|
|
21
37
|
require 'support/app/post'
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# Mongoid models
|
|
41
|
+
begin
|
|
42
|
+
require 'support/app/image'
|
|
43
|
+
require 'support/app/mongoid_article'
|
|
44
|
+
rescue
|
|
45
|
+
$stderr.puts("'mongoid' gem is not installed, could not load Mongoid models")
|
|
46
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: elasticsearch-model
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 7.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Karel Minarik
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-08-
|
|
11
|
+
date: 2019-08-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: elasticsearch
|
|
@@ -347,6 +347,7 @@ files:
|
|
|
347
347
|
- gemfiles/3.0.gemfile
|
|
348
348
|
- gemfiles/4.0.gemfile
|
|
349
349
|
- gemfiles/5.0.gemfile
|
|
350
|
+
- gemfiles/6.0.gemfile
|
|
350
351
|
- lib/elasticsearch/model.rb
|
|
351
352
|
- lib/elasticsearch/model/adapter.rb
|
|
352
353
|
- lib/elasticsearch/model/adapters/active_record.rb
|
|
@@ -398,7 +399,6 @@ files:
|
|
|
398
399
|
- spec/elasticsearch/model/indexing_spec.rb
|
|
399
400
|
- spec/elasticsearch/model/module_spec.rb
|
|
400
401
|
- spec/elasticsearch/model/multimodel_spec.rb
|
|
401
|
-
- spec/elasticsearch/model/naming_inheritance_spec.rb
|
|
402
402
|
- spec/elasticsearch/model/naming_spec.rb
|
|
403
403
|
- spec/elasticsearch/model/proxy_spec.rb
|
|
404
404
|
- spec/elasticsearch/model/response/aggregations_spec.rb
|
|
@@ -417,6 +417,7 @@ files:
|
|
|
417
417
|
- spec/support/app/answer.rb
|
|
418
418
|
- spec/support/app/article.rb
|
|
419
419
|
- spec/support/app/article_for_pagination.rb
|
|
420
|
+
- spec/support/app/article_no_type.rb
|
|
420
421
|
- spec/support/app/article_with_custom_serialization.rb
|
|
421
422
|
- spec/support/app/article_with_dynamic_index_name.rb
|
|
422
423
|
- spec/support/app/author.rb
|
|
@@ -455,7 +456,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
455
456
|
- !ruby/object:Gem::Version
|
|
456
457
|
version: '0'
|
|
457
458
|
requirements: []
|
|
458
|
-
rubygems_version: 3.0.
|
|
459
|
+
rubygems_version: 3.0.6
|
|
459
460
|
signing_key:
|
|
460
461
|
specification_version: 4
|
|
461
462
|
summary: ActiveModel/Record integrations for Elasticsearch.
|
|
@@ -483,7 +484,6 @@ test_files:
|
|
|
483
484
|
- spec/elasticsearch/model/indexing_spec.rb
|
|
484
485
|
- spec/elasticsearch/model/module_spec.rb
|
|
485
486
|
- spec/elasticsearch/model/multimodel_spec.rb
|
|
486
|
-
- spec/elasticsearch/model/naming_inheritance_spec.rb
|
|
487
487
|
- spec/elasticsearch/model/naming_spec.rb
|
|
488
488
|
- spec/elasticsearch/model/proxy_spec.rb
|
|
489
489
|
- spec/elasticsearch/model/response/aggregations_spec.rb
|
|
@@ -502,6 +502,7 @@ test_files:
|
|
|
502
502
|
- spec/support/app/answer.rb
|
|
503
503
|
- spec/support/app/article.rb
|
|
504
504
|
- spec/support/app/article_for_pagination.rb
|
|
505
|
+
- spec/support/app/article_no_type.rb
|
|
505
506
|
- spec/support/app/article_with_custom_serialization.rb
|
|
506
507
|
- spec/support/app/article_with_dynamic_index_name.rb
|
|
507
508
|
- spec/support/app/author.rb
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe 'naming inheritance' do
|
|
4
|
-
|
|
5
|
-
context 'without using proxy' do
|
|
6
|
-
before(:all) do
|
|
7
|
-
TestBase = Class.new do
|
|
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
|
|
32
|
-
|
|
33
|
-
extend Elasticsearch::Model::Naming::ClassMethods
|
|
34
|
-
include Elasticsearch::Model::Naming::InstanceMethods
|
|
35
|
-
|
|
36
|
-
index_name "cats"
|
|
37
|
-
document_type "cat"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
after(:all) do
|
|
43
|
-
remove_classes(TestBase, Animal, MyNamespace, Cat)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
around(:all) do |example|
|
|
47
|
-
original_value = Elasticsearch::Model.inheritance_enabled
|
|
48
|
-
Elasticsearch::Model.inheritance_enabled = true
|
|
49
|
-
example.run
|
|
50
|
-
Elasticsearch::Model.inheritance_enabled = original_value
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
describe '#index_name' do
|
|
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')
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
describe '#document_type' do
|
|
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
|
|
85
|
-
|
|
86
|
-
it 'returns the explicit document type' do
|
|
87
|
-
expect(Animal.document_type).to eq('mammal')
|
|
88
|
-
expect(Animal.new.document_type).to eq('mammal')
|
|
89
|
-
|
|
90
|
-
expect(Cat.document_type).to eq('cat')
|
|
91
|
-
expect(Cat.new.document_type).to eq('cat')
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
it 'returns the ancestor document type' do
|
|
95
|
-
expect(Dog.document_type).to eq('mammal')
|
|
96
|
-
expect(Dog.new.document_type).to eq('mammal')
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
it 'returns the ancestor document type for namespaced models' do
|
|
100
|
-
expect(::MyNamespace::Dog.document_type).to eq('mammal')
|
|
101
|
-
expect(::MyNamespace::Dog.new.document_type).to eq('mammal')
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
context 'when using proxy' do
|
|
107
|
-
before(:all) do
|
|
108
|
-
TestBase = Class.new do
|
|
109
|
-
extend ActiveModel::Naming
|
|
110
|
-
|
|
111
|
-
include Elasticsearch::Model
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
Animal = Class.new TestBase do
|
|
115
|
-
index_name "mammals"
|
|
116
|
-
document_type "mammal"
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
Dog = Class.new Animal
|
|
120
|
-
|
|
121
|
-
module MyNamespace
|
|
122
|
-
Dog = Class.new Animal
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
Cat = Class.new Animal do
|
|
126
|
-
index_name "cats"
|
|
127
|
-
document_type "cat"
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
after(:all) do
|
|
132
|
-
remove_classes(TestBase, Animal, MyNamespace, Cat)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
around(:all) do |example|
|
|
136
|
-
original_value = Elasticsearch::Model.settings[:inheritance_enabled]
|
|
137
|
-
Elasticsearch::Model.settings[:inheritance_enabled] = true
|
|
138
|
-
example.run
|
|
139
|
-
Elasticsearch::Model.settings[:inheritance_enabled] = original_value
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
describe '#index_name' do
|
|
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
|
|
157
|
-
|
|
158
|
-
it 'returns the ancestor index name for namespaced models' do
|
|
159
|
-
expect(::MyNamespace::Dog.index_name).to eq('mammals')
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
describe '#document_type' do
|
|
164
|
-
|
|
165
|
-
it 'returns nil' do
|
|
166
|
-
expect(TestBase.document_type).to eq('_doc')
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
it 'returns the explicit document type' do
|
|
170
|
-
expect(Animal.document_type).to eq('mammal')
|
|
171
|
-
|
|
172
|
-
expect(Cat.document_type).to eq('cat')
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
it 'returns the ancestor document type' do
|
|
176
|
-
expect(Dog.document_type).to eq('mammal')
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
it 'returns the ancestor document type for namespaced models' do
|
|
180
|
-
expect(::MyNamespace::Dog.document_type).to eq('mammal')
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
end
|