From e9e9c2a09791dc2b5a9831eca3f64de497307cfa Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 6 May 2017 15:46:30 -0700 Subject: [PATCH] Raise an error with incompatible fields options --- lib/searchkick/query.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/searchkick/query.rb b/lib/searchkick/query.rb index 7a2a39f..97d1e6d 100644 --- a/lib/searchkick/query.rb +++ b/lib/searchkick/query.rb @@ -484,15 +484,18 @@ module Searchkick def set_fields boost_fields = {} fields = options[:fields] || searchkick_options[:searchable] + default_match = options[:match] || searchkick_options[:match] || :word fields = if fields fields.map do |value| - k, v = value.is_a?(Hash) ? value.to_a.first : [value, options[:match] || searchkick_options[:match] || :word] + k, v = value.is_a?(Hash) ? value.to_a.first : [value, default_match] k2, boost = k.to_s.split("^", 2) field = "#{k2}.#{v == :word ? 'analyzed' : v}" boost_fields[field] = boost.to_f if boost field end + elsif default_match != :word + raise ArgumentError, "Must specify fields" else ["_all"] end -- libgit2 0.21.0