Commit 1a0ff891d3a1367b1760df6e3389a7fbbaf4e720
1 parent
88349791
Exists in
master
and in
21 other branches
Added max_expansions option to misspellings
Showing
1 changed file
with
2 additions
and
1 deletions
Show diff stats
lib/searchkick/query.rb
... | ... | @@ -111,6 +111,7 @@ module Searchkick |
111 | 111 | edit_distance = (misspellings.is_a?(Hash) && (misspellings[:edit_distance] || misspellings[:distance])) || 1 |
112 | 112 | transpositions = (misspellings.is_a?(Hash) && misspellings[:transpositions] == true) ? {fuzzy_transpositions: true} : {} |
113 | 113 | prefix_length = (misspellings.is_a?(Hash) && misspellings[:prefix_length]) || 0 |
114 | + max_expansions = (misspellings.is_a?(Hash) && misspellings[:max_expansions]) || 3 | |
114 | 115 | end |
115 | 116 | |
116 | 117 | if field == "_all" || field.end_with?(".analyzed") |
... | ... | @@ -128,7 +129,7 @@ module Searchkick |
128 | 129 | end |
129 | 130 | |
130 | 131 | if misspellings != false |
131 | - qs.concat qs.map { |q| q.except(:cutoff_frequency).merge(fuzziness: edit_distance, prefix_length: prefix_length, max_expansions: 3, boost: factor).merge(transpositions) } | |
132 | + qs.concat qs.map { |q| q.except(:cutoff_frequency).merge(fuzziness: edit_distance, prefix_length: prefix_length, max_expansions: max_expansions, boost: factor).merge(transpositions) } | |
132 | 133 | end |
133 | 134 | |
134 | 135 | queries.concat(qs.map { |q| {match: {field => q}} }) | ... | ... |