Commit 4e0a794044d14ee5ce3a91ffa94043db992a71a9
1 parent
ee761d52
Exists in
master
and in
17 other branches
Fixed custom mappings - fixes #1272 closes #1271
Co-authored-by: Stanislav Kravtsov <my-blizz4rd@hotmail.com>
Showing
5 changed files
with
8 additions
and
6 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/index_options.rb
... | ... | @@ -13,7 +13,7 @@ module Searchkick |
13 | 13 | index_type = index_type.call if index_type.respond_to?(:call) |
14 | 14 | end |
15 | 15 | |
16 | - custom_mapping = options[:mapping] || {} | |
16 | + custom_mapping = options[:mappings] || {} | |
17 | 17 | if below70 && custom_mapping.keys.map(&:to_sym).include?(:properties) |
18 | 18 | # add type |
19 | 19 | custom_mapping = {index_type => custom_mapping} | ... | ... |
test/errors_test.rb
... | ... | @@ -9,7 +9,6 @@ class ErrorsTest < Minitest::Test |
9 | 9 | name: {type: "date"} |
10 | 10 | } |
11 | 11 | } |
12 | - mapping = {product: mapping} if Searchkick.server_below?("7.0.0") | |
13 | 12 | index = Searchkick::Index.new "dogs", mappings: mapping |
14 | 13 | index.delete if index.exists? |
15 | 14 | index.create_index | ... | ... |
test/index_test.rb
... | ... | @@ -47,10 +47,12 @@ class IndexTest < Minitest::Test |
47 | 47 | assert_equal 1, Product.searchkick_index.total_docs |
48 | 48 | end |
49 | 49 | |
50 | - def test_mapping | |
50 | + def test_mappings | |
51 | 51 | store_names ["Dollar Tree"], Store |
52 | - assert_equal [], Store.search(body: {query: {match: {name: "dollar"}}}).map(&:name) | |
53 | - assert_equal ["Dollar Tree"], Store.search(body: {query: {match: {name: "Dollar Tree"}}}).map(&:name) | |
52 | + assert_equal ["Dollar Tree"], Store.search(body: {query: {match: {name: "dollar"}}}).map(&:name) | |
53 | + mapping = Store.search_index.mapping.values.first["mappings"] | |
54 | + mapping = mapping["store"] if Searchkick.server_below?("7.0.0") | |
55 | + assert_equal "text", mapping["properties"]["name"]["type"] | |
54 | 56 | end |
55 | 57 | |
56 | 58 | def test_body | ... | ... |