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.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/Gemfile +17 -0
- data/LICENSE.txt +199 -10
- data/README.md +17 -16
- data/Rakefile +18 -1
- 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.rb +25 -15
- 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.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.rb +17 -0
- 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/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/searching.rb +17 -0
- data/lib/elasticsearch/model/serializing.rb +17 -0
- data/lib/elasticsearch/model/version.rb +18 -1
- 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 +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.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
- 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 'spec_helper'
|
|
2
19
|
|
|
3
20
|
describe 'Elasticsearch::Model::Adapter::ActiveRecord Dynamic Index naming' 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::Adapter::ActiveRecord Importing' 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::Adapter::ActiveRecord MultiModel' 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::Adapter::ActiveRecord Namespaced Model' do
|
|
@@ -10,7 +27,7 @@ describe 'Elasticsearch::Model::Adapter::ActiveRecord Namespaced Model' do
|
|
|
10
27
|
end
|
|
11
28
|
|
|
12
29
|
MyNamespace::Book.delete_all
|
|
13
|
-
MyNamespace::Book.__elasticsearch__.create_index!(force: true)
|
|
30
|
+
MyNamespace::Book.__elasticsearch__.create_index!(force: true, include_type_name: true)
|
|
14
31
|
MyNamespace::Book.create!(title: 'Test')
|
|
15
32
|
MyNamespace::Book.__elasticsearch__.refresh_index!
|
|
16
33
|
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::Adapter::ActiveRecord Pagination' 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::Adapter::ActiveRecord Parent-Child' do
|
|
@@ -21,7 +38,7 @@ describe 'Elasticsearch::Model::Adapter::ActiveRecord Parent-Child' do
|
|
|
21
38
|
add_index(:answers, :question_id) unless index_exists?(:answers, :question_id)
|
|
22
39
|
|
|
23
40
|
clear_tables(Question)
|
|
24
|
-
ParentChildSearchable.create_index!(force: true)
|
|
41
|
+
ParentChildSearchable.create_index!(force: true, include_type_name: true)
|
|
25
42
|
|
|
26
43
|
q_1 = Question.create!(title: 'First Question', author: 'John')
|
|
27
44
|
q_2 = Question.create!(title: 'Second Question', author: 'Jody')
|
|
@@ -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::Adapter::ActiveRecord Serialization' 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::Adapter::ActiveRecord 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::Adapter::Default 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::Adapter::Mongoid, if: test_mongoid? 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::Adapter::ActiveRecord Multimodel', if: test_mongoid? 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::Adapter::Mongoid 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::Adapter::Multiple 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::Callbacks 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::Client 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::HashWrapper, if: Hashie::VERSION >= '3.5.3' 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::Importing 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::Indexing do
|
|
@@ -84,10 +101,8 @@ describe Elasticsearch::Model::Indexing do
|
|
|
84
101
|
expect(DummyIndexingModel.mappings).to be_a(Elasticsearch::Model::Indexing::Mappings)
|
|
85
102
|
end
|
|
86
103
|
|
|
87
|
-
it '
|
|
88
|
-
expect
|
|
89
|
-
Elasticsearch::Model::Indexing::Mappings.new
|
|
90
|
-
}.to raise_exception(ArgumentError)
|
|
104
|
+
it 'does not raise an exception when there is no type passed to the #initialize method' do
|
|
105
|
+
expect(Elasticsearch::Model::Indexing::Mappings.new)
|
|
91
106
|
end
|
|
92
107
|
|
|
93
108
|
it 'should be convertible to a hash' do
|
|
@@ -98,7 +113,7 @@ describe Elasticsearch::Model::Indexing do
|
|
|
98
113
|
expect(Elasticsearch::Model::Indexing::Mappings.new(:mytype, { foo: 'bar' }).as_json).to eq(expected_mapping_hash)
|
|
99
114
|
end
|
|
100
115
|
|
|
101
|
-
context 'when
|
|
116
|
+
context 'when a type is specified' do
|
|
102
117
|
|
|
103
118
|
let(:mappings) do
|
|
104
119
|
Elasticsearch::Model::Indexing::Mappings.new(:mytype)
|
|
@@ -113,6 +128,65 @@ describe Elasticsearch::Model::Indexing do
|
|
|
113
128
|
expect(mappings.to_hash[:mytype][:properties][:foo][:type]).to eq('boolean')
|
|
114
129
|
end
|
|
115
130
|
|
|
131
|
+
it 'uses text as the default field type' do
|
|
132
|
+
expect(mappings.to_hash[:mytype][:properties][:bar][:type]).to eq('text')
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
context 'when the \'include_type_name\' option is specified' do
|
|
136
|
+
|
|
137
|
+
let(:mappings) do
|
|
138
|
+
Elasticsearch::Model::Indexing::Mappings.new(:mytype, include_type_name: true)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
before do
|
|
142
|
+
mappings.indexes :foo, { type: 'boolean', include_in_all: false }
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it 'creates the correct mapping definition' do
|
|
146
|
+
expect(mappings.to_hash[:mytype][:properties][:foo][:type]).to eq('boolean')
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it 'sets the \'include_type_name\' option' do
|
|
150
|
+
expect(mappings.to_hash[:mytype][:include_type_name]).to eq(true)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
context 'when a type is not specified' do
|
|
156
|
+
|
|
157
|
+
let(:mappings) do
|
|
158
|
+
Elasticsearch::Model::Indexing::Mappings.new
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
before do
|
|
162
|
+
mappings.indexes :foo, { type: 'boolean', include_in_all: false }
|
|
163
|
+
mappings.indexes :bar
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it 'creates the correct mapping definition' do
|
|
167
|
+
expect(mappings.to_hash[:properties][:foo][:type]).to eq('boolean')
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it 'uses text as the default type' do
|
|
171
|
+
expect(mappings.to_hash[:properties][:bar][:type]).to eq('text')
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
context 'when specific mappings are defined' do
|
|
176
|
+
|
|
177
|
+
let(:mappings) do
|
|
178
|
+
Elasticsearch::Model::Indexing::Mappings.new(:mytype, include_type_name: true)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
before do
|
|
182
|
+
mappings.indexes :foo, { type: 'boolean', include_in_all: false }
|
|
183
|
+
mappings.indexes :bar
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
it 'creates the correct mapping definition' do
|
|
187
|
+
expect(mappings.to_hash[:mytype][:properties][:foo][:type]).to eq('boolean')
|
|
188
|
+
end
|
|
189
|
+
|
|
116
190
|
it 'uses text as the default type' do
|
|
117
191
|
expect(mappings.to_hash[:mytype][:properties][:bar][:type]).to eq('text')
|
|
118
192
|
end
|
|
@@ -169,6 +243,10 @@ describe Elasticsearch::Model::Indexing do
|
|
|
169
243
|
expect(mappings.to_hash[:mytype][:properties][:foo_nested_as_symbol][:properties]).not_to be_nil
|
|
170
244
|
expect(mappings.to_hash[:mytype][:properties][:foo_nested_as_symbol][:fields]).to be_nil
|
|
171
245
|
end
|
|
246
|
+
|
|
247
|
+
it 'defines the settings' do
|
|
248
|
+
expect(mappings.to_hash[:mytype][:include_type_name]).to be(true)
|
|
249
|
+
end
|
|
172
250
|
end
|
|
173
251
|
end
|
|
174
252
|
|
|
@@ -180,7 +258,7 @@ describe Elasticsearch::Model::Indexing do
|
|
|
180
258
|
end
|
|
181
259
|
|
|
182
260
|
let(:expected_mappings_hash) do
|
|
183
|
-
{
|
|
261
|
+
{ foo: "boo", bar: "bam", properties: {} }
|
|
184
262
|
end
|
|
185
263
|
|
|
186
264
|
it 'sets the mappings' do
|
|
@@ -196,7 +274,25 @@ describe Elasticsearch::Model::Indexing do
|
|
|
196
274
|
end
|
|
197
275
|
|
|
198
276
|
it 'sets the mappings' do
|
|
199
|
-
expect(DummyIndexingModel.mapping.to_hash[:
|
|
277
|
+
expect(DummyIndexingModel.mapping.to_hash[:properties][:foo][:type]).to eq('boolean')
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
context 'when the class has a document_type' do
|
|
282
|
+
|
|
283
|
+
before do
|
|
284
|
+
DummyIndexingModel.instance_variable_set(:@mapping, nil)
|
|
285
|
+
DummyIndexingModel.document_type(:mytype)
|
|
286
|
+
DummyIndexingModel.mappings(foo: 'boo')
|
|
287
|
+
DummyIndexingModel.mappings(bar: 'bam')
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
let(:expected_mappings_hash) do
|
|
291
|
+
{ mytype: { foo: "boo", bar: "bam", properties: {} } }
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
it 'sets the mappings' do
|
|
295
|
+
expect(DummyIndexingModel.mappings.to_hash).to eq(expected_mappings_hash)
|
|
200
296
|
end
|
|
201
297
|
end
|
|
202
298
|
end
|
|
@@ -738,8 +834,8 @@ describe Elasticsearch::Model::Indexing do
|
|
|
738
834
|
context 'when options are not provided' do
|
|
739
835
|
|
|
740
836
|
let(:expected_body) do
|
|
741
|
-
{ mappings: {
|
|
742
|
-
type: 'text' } } }
|
|
837
|
+
{ mappings: { properties: { foo: { analyzer: 'keyword',
|
|
838
|
+
type: 'text' } } },
|
|
743
839
|
settings: { index: { number_of_shards: 1 } } }
|
|
744
840
|
end
|
|
745
841
|
|
|
@@ -789,8 +885,8 @@ describe Elasticsearch::Model::Indexing do
|
|
|
789
885
|
|
|
790
886
|
before do
|
|
791
887
|
expect(DummyIndexingModelForCreate).to receive(:client).and_return(client)
|
|
792
|
-
expect(DummyIndexingModelForCreate).to receive(:index_exists?).and_return(false)
|
|
793
888
|
expect(DummyIndexingModelForCreate).to receive(:delete_index!).and_return(true)
|
|
889
|
+
expect(DummyIndexingModelForCreate).to receive(:index_exists?).and_return(false)
|
|
794
890
|
expect(indices).to receive(:create).and_raise(Exception)
|
|
795
891
|
end
|
|
796
892
|
|
|
@@ -810,8 +906,8 @@ describe Elasticsearch::Model::Indexing do
|
|
|
810
906
|
end
|
|
811
907
|
|
|
812
908
|
let(:expected_body) do
|
|
813
|
-
{ mappings: {
|
|
814
|
-
type: 'text' } } }
|
|
909
|
+
{ mappings: { properties: { foo: { analyzer: 'keyword',
|
|
910
|
+
type: 'text' } } },
|
|
815
911
|
settings: { index: { number_of_shards: 1 } } }
|
|
816
912
|
end
|
|
817
913
|
|