Commit 3dc4776bb69b5f2c59d29f48fd7edf618d887ee9

Authored by Andrew Kane
1 parent 6088da6d

Fixes for ES6 beta1

@@ -33,6 +33,7 @@ matrix: @@ -33,6 +33,7 @@ matrix:
33 - gemfile: Gemfile 33 - gemfile: Gemfile
34 env: ELASTICSEARCH_VERSION=5.0.1 34 env: ELASTICSEARCH_VERSION=5.0.1
35 jdk: oraclejdk8 35 jdk: oraclejdk8
  36 + allow_failures:
36 - gemfile: Gemfile 37 - gemfile: Gemfile
37 - env: ELASTICSEARCH_VERSION=6.0.0-alpha2 38 + env: ELASTICSEARCH_VERSION=6.0.0-beta1
38 jdk: oraclejdk8 39 jdk: oraclejdk8
lib/searchkick/index.rb
@@ -15,7 +15,13 @@ module Searchkick @@ -15,7 +15,13 @@ module Searchkick
15 end 15 end
16 16
17 def delete 17 def delete
18 - client.indices.delete index: name 18 + if !Searchkick.server_below?("6.0.0-alpha1") && alias_exists?
  19 + # can't call delete directly on aliases in ES 6
  20 + indices = client.indices.get_alias(name: name).keys
  21 + client.indices.delete index: indices
  22 + else
  23 + client.indices.delete index: name
  24 + end
19 end 25 end
20 26
21 def exists? 27 def exists?
lib/searchkick/index_options.rb
@@ -162,11 +162,6 @@ module Searchkick @@ -162,11 +162,6 @@ module Searchkick
162 settings[:similarity] = {default: {type: options[:similarity]}} 162 settings[:similarity] = {default: {type: options[:similarity]}}
163 end 163 end
164 164
165 - unless below60  
166 - settings[:mapping] ||= {}  
167 - settings[:mapping][:single_type] = false  
168 - end  
169 -  
170 settings.deep_merge!(options[:settings] || {}) 165 settings.deep_merge!(options[:settings] || {})
171 166
172 # synonyms 167 # synonyms
@@ -188,7 +183,7 @@ module Searchkick @@ -188,7 +183,7 @@ module Searchkick
188 # - Only apply the synonym expansion at index time 183 # - Only apply the synonym expansion at index time
189 # - Don't have the synonym filter applied search 184 # - Don't have the synonym filter applied search
190 # - Use directional synonyms where appropriate. You want to make sure that you're not injecting terms that are too general. 185 # - Use directional synonyms where appropriate. You want to make sure that you're not injecting terms that are too general.
191 - settings[:analysis][:analyzer][default_analyzer][:filter].insert(4, "searchkick_synonym") 186 + settings[:analysis][:analyzer][default_analyzer][:filter].insert(4, "searchkick_synonym") if below60
192 settings[:analysis][:analyzer][default_analyzer][:filter] << "searchkick_synonym" 187 settings[:analysis][:analyzer][default_analyzer][:filter] << "searchkick_synonym"
193 188
194 %w(word_start word_middle word_end).each do |type| 189 %w(word_start word_middle word_end).each do |type|
test/highlight_test.rb
@@ -32,7 +32,7 @@ class HighlightTest &lt; Minitest::Test @@ -32,7 +32,7 @@ class HighlightTest &lt; Minitest::Test
32 32
33 def test_field_options 33 def test_field_options
34 store_names ["Two Door Cinema Club are a Northern Irish indie rock band"] 34 store_names ["Two Door Cinema Club are a Northern Irish indie rock band"]
35 - fragment_size = ENV["MATCH"] == "word_start" ? 26 : 20 35 + fragment_size = ENV["MATCH"] == "word_start" ? 26 : 21
36 assert_equal "Two Door <em>Cinema</em> Club are", Product.search("cinema", fields: [:name], highlight: {fields: {name: {fragment_size: fragment_size}}}).first.search_highlights[:name] 36 assert_equal "Two Door <em>Cinema</em> Club are", Product.search("cinema", fields: [:name], highlight: {fields: {name: {fragment_size: fragment_size}}}).first.search_highlights[:name]
37 end 37 end
38 38