Commit e9e9c2a09791dc2b5a9831eca3f64de497307cfa
1 parent
f403e4cf
Exists in
master
and in
19 other branches
Raise an error with incompatible fields options
Showing
1 changed file
with
4 additions
and
1 deletions
Show diff stats
lib/searchkick/query.rb
... | ... | @@ -484,15 +484,18 @@ module Searchkick |
484 | 484 | def set_fields |
485 | 485 | boost_fields = {} |
486 | 486 | fields = options[:fields] || searchkick_options[:searchable] |
487 | + default_match = options[:match] || searchkick_options[:match] || :word | |
487 | 488 | fields = |
488 | 489 | if fields |
489 | 490 | fields.map do |value| |
490 | - k, v = value.is_a?(Hash) ? value.to_a.first : [value, options[:match] || searchkick_options[:match] || :word] | |
491 | + k, v = value.is_a?(Hash) ? value.to_a.first : [value, default_match] | |
491 | 492 | k2, boost = k.to_s.split("^", 2) |
492 | 493 | field = "#{k2}.#{v == :word ? 'analyzed' : v}" |
493 | 494 | boost_fields[field] = boost.to_f if boost |
494 | 495 | field |
495 | 496 | end |
497 | + elsif default_match != :word | |
498 | + raise ArgumentError, "Must specify fields" | |
496 | 499 | else |
497 | 500 | ["_all"] |
498 | 501 | end | ... | ... |