Commit 5cf51a9f078bd04635f717a14fd627ead89a1a08

Authored by Andrew Kane
1 parent 390878f3

Added match option to searchkick method

lib/searchkick/index.rb
... ... @@ -464,10 +464,13 @@ module Searchkick
464 464 "{name}" => {type: "string", index: "not_analyzed"}
465 465 }
466 466  
467   - unless options[:word] == false
  467 + if options[:match] && options[:match] != :word
  468 + dynamic_fields[options[:match]] = {type: "string", index: "analyzed", analyzer: "searchkick_#{options[:match]}_index"}
  469 + elsif options[:word] != false
468 470 dynamic_fields["analyzed"] = {type: "string", index: "analyzed"}
469 471 end
470 472  
  473 +
471 474 mappings = {
472 475 _default_: {
473 476 properties: mapping,
... ...
lib/searchkick/query.rb
... ... @@ -30,7 +30,7 @@ module Searchkick
30 30 options[:fields].map { |f| "#{f}.autocomplete" }
31 31 else
32 32 options[:fields].map do |value|
33   - k, v = value.is_a?(Hash) ? value.to_a.first : [value, options[:match] || :word]
  33 + k, v = value.is_a?(Hash) ? value.to_a.first : [value, options[:match] || searchkick_options[:match] || :word]
34 34 k2, boost = k.to_s.split("^", 2)
35 35 field = "#{k2}.#{v == :word ? 'analyzed' : v}"
36 36 boost_fields[field] = boost.to_f if boost
... ...