Commit dc19c470f60e0b34f5a2793c2967a7b9abe40ea7

Authored by Andrew
1 parent a01b0832

Removed log option in favor of modifier [skip ci]

Showing 2 changed files with 6 additions and 6 deletions   Show diff stats
CHANGELOG.md
... ... @@ -7,6 +7,7 @@
7 7 - Bumped default `limit` to 10,000
8 8 - The `_all` field is disabled by default in Elasticsearch 5. Use `searchkick _all: true` if you need it.
9 9 - An `ArgumentError` is raised instead of a warning when options are incompatible with the `body` option
  10 +- Removed `log` option from `boost_by`. Use `modifier: "ln2p"` instead.
10 11  
11 12 ## 2.5.1 [unreleased]
12 13  
... ...
lib/searchkick/query.rb
... ... @@ -591,7 +591,7 @@ module Searchkick
591 591 end
592 592 boost_by[options[:boost]] = {factor: 1} if options[:boost]
593 593  
594   - custom_filters.concat boost_filters(boost_by, log: true)
  594 + custom_filters.concat boost_filters(boost_by, modifier: "ln2p")
595 595 multiply_filters.concat boost_filters(multiply_by || {})
596 596 end
597 597  
... ... @@ -906,15 +906,14 @@ module Searchkick
906 906 }
907 907 end
908 908  
909   - def boost_filters(boost_by, options = {})
  909 + def boost_filters(boost_by, modifier: nil)
910 910 boost_by.map do |field, value|
911   - log = value.key?(:log) ? value[:log] : options[:log]
912   - value[:factor] ||= 1
  911 + raise ArgumentError, "Use modifier: \"ln2p\" instead" if value.key?(:log)
913 912 script_score = {
914 913 field_value_factor: {
915 914 field: field,
916   - factor: value[:factor].to_f,
917   - modifier: value[:modifier] || (log ? "ln2p" : nil)
  915 + factor: (value[:factor] || 1).to_f,
  916 + modifier: value[:modifier] || modifier
918 917 }
919 918 }
920 919  
... ...