Commit 64b2e069172d3b2c542956ffb47435157a12b345
1 parent
08b142e6
Exists in
master
and in
15 other branches
Fixed cutoff_frequency deprecation warning
Showing
2 changed files
with
18 additions
and
2 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/query.rb
... | ... | @@ -350,7 +350,7 @@ module Searchkick |
350 | 350 | field_misspellings = misspellings && (!misspellings_fields || misspellings_fields.include?(base_field(field))) |
351 | 351 | |
352 | 352 | if field == "_all" || field.end_with?(".analyzed") |
353 | - shared_options[:cutoff_frequency] = 0.001 unless operator.to_s == "and" || field_misspellings == false | |
353 | + shared_options[:cutoff_frequency] = 0.001 unless operator.to_s == "and" || field_misspellings == false || (!below73? && !track_total_hits?) | |
354 | 354 | qs << shared_options.merge(analyzer: "searchkick_search") |
355 | 355 | |
356 | 356 | # searchkick_search and searchkick_search2 are the same for ukrainian |
... | ... | @@ -522,7 +522,7 @@ module Searchkick |
522 | 522 | # routing |
523 | 523 | @routing = options[:routing] if options[:routing] |
524 | 524 | |
525 | - if searchkick_options[:deep_paging] && !below70? | |
525 | + if track_total_hits? | |
526 | 526 | payload[:track_total_hits] = true |
527 | 527 | end |
528 | 528 | |
... | ... | @@ -1100,6 +1100,14 @@ module Searchkick |
1100 | 1100 | k.sub(/\.(analyzed|word_start|word_middle|word_end|text_start|text_middle|text_end|exact)\z/, "") |
1101 | 1101 | end |
1102 | 1102 | |
1103 | + def track_total_hits? | |
1104 | + (searchkick_options[:deep_paging] && !below70?) || body_options[:track_total_hits] | |
1105 | + end | |
1106 | + | |
1107 | + def body_options | |
1108 | + options[:body_options] || {} | |
1109 | + end | |
1110 | + | |
1103 | 1111 | def below61? |
1104 | 1112 | Searchkick.server_below?("6.1.0") |
1105 | 1113 | end |
... | ... | @@ -1108,6 +1116,10 @@ module Searchkick |
1108 | 1116 | Searchkick.server_below?("7.0.0") |
1109 | 1117 | end |
1110 | 1118 | |
1119 | + def below73? | |
1120 | + Searchkick.server_below?("7.3.0") | |
1121 | + end | |
1122 | + | |
1111 | 1123 | def below75? |
1112 | 1124 | Searchkick.server_below?("7.5.0") |
1113 | 1125 | end | ... | ... |