Commit a430c44639ead7e3606e8c65cf061eeb416dbe4e

Authored by Andrew Kane
1 parent 656cc5dd

Do not use all fields when searchable specified

Showing 1 changed file with 4 additions and 3 deletions   Show diff stats
lib/searchkick/query.rb
... ... @@ -122,12 +122,13 @@ module Searchkick
122 122  
123 123 def prepare
124 124 boost_fields = {}
  125 + fields = options[:fields] || searchkick_options[:searchable]
125 126 fields =
126   - if options[:fields]
  127 + if fields
127 128 if options[:autocomplete]
128   - options[:fields].map { |f| "#{f}.autocomplete" }
  129 + fields.map { |f| "#{f}.autocomplete" }
129 130 else
130   - options[:fields].map do |value|
  131 + fields.map do |value|
131 132 k, v = value.is_a?(Hash) ? value.to_a.first : [value, options[:match] || searchkick_options[:match] || :word]
132 133 k2, boost = k.to_s.split("^", 2)
133 134 field = "#{k2}.#{v == :word ? 'analyzed' : v}"
... ...