Commit e620deaad9723a59ca3206ab1e3da7085cfad53e
1 parent
6cfa3a48
Exists in
master
and in
21 other branches
Added support for Elasticsearch 1.4
Showing
3 changed files
with
4 additions
and
2 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/query.rb
... | ... | @@ -16,6 +16,7 @@ module Searchkick |
16 | 16 | @options = options |
17 | 17 | |
18 | 18 | below12 = Gem::Version.new(Searchkick.server_version) < Gem::Version.new("1.2") |
19 | + below14 = Gem::Version.new(Searchkick.server_version) < Gem::Version.new("1.4") | |
19 | 20 | |
20 | 21 | boost_fields = {} |
21 | 22 | fields = |
... | ... | @@ -279,7 +280,7 @@ module Searchkick |
279 | 280 | payload[:facets][field] = { |
280 | 281 | terms_stats: { |
281 | 282 | key_field: field, |
282 | - value_script: "doc.score", | |
283 | + value_script: below14 ? "doc.score" : "_score", | |
283 | 284 | size: size |
284 | 285 | } |
285 | 286 | } | ... | ... |
lib/searchkick/reindex.rb
... | ... | @@ -40,7 +40,7 @@ module Searchkick |
40 | 40 | # remove old indices that start w/ index_name |
41 | 41 | def clean_indices |
42 | 42 | all_indices = Searchkick.client.indices.get_aliases |
43 | - indices = all_indices.select{|k, v| v["aliases"].empty? && k =~ /\A#{Regexp.escape(searchkick_index.name)}_\d{14,17}\z/ }.keys | |
43 | + indices = all_indices.select{|k, v| (v.empty? || v["aliases"].empty?) && k =~ /\A#{Regexp.escape(searchkick_index.name)}_\d{14,17}\z/ }.keys | |
44 | 44 | indices.each do |index| |
45 | 45 | Searchkick::Index.new(index).delete |
46 | 46 | end | ... | ... |