Commit 148a213e3154ce8985cb6ea2c062ee00e630ca46
1 parent
e9e9c2a0
Exists in
master
and in
19 other branches
Fixed phrase matches with _all field
Showing
1 changed file
with
12 additions
and
4 deletions
Show diff stats
lib/searchkick/query.rb
... | ... | @@ -279,7 +279,13 @@ module Searchkick |
279 | 279 | |
280 | 280 | match_type = |
281 | 281 | if field.end_with?(".phrase") |
282 | - field = field.sub(/\.phrase\z/, ".analyzed") | |
282 | + field = | |
283 | + if field == "_all.phrase" | |
284 | + "_all" | |
285 | + else | |
286 | + field.sub(/\.phrase\z/, ".analyzed") | |
287 | + end | |
288 | + | |
283 | 289 | :match_phrase |
284 | 290 | else |
285 | 291 | :match |
... | ... | @@ -494,10 +500,12 @@ module Searchkick |
494 | 500 | boost_fields[field] = boost.to_f if boost |
495 | 501 | field |
496 | 502 | end |
497 | - elsif default_match != :word | |
498 | - raise ArgumentError, "Must specify fields" | |
499 | - else | |
503 | + elsif default_match == :word | |
500 | 504 | ["_all"] |
505 | + elsif default_match == :phrase | |
506 | + ["_all.phrase"] | |
507 | + else | |
508 | + raise ArgumentError, "Must specify fields" | |
501 | 509 | end |
502 | 510 | [boost_fields, fields] |
503 | 511 | end | ... | ... |