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,7 +279,13 @@ module Searchkick | ||
279 | 279 | ||
280 | match_type = | 280 | match_type = |
281 | if field.end_with?(".phrase") | 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 | :match_phrase | 289 | :match_phrase |
284 | else | 290 | else |
285 | :match | 291 | :match |
@@ -494,10 +500,12 @@ module Searchkick | @@ -494,10 +500,12 @@ module Searchkick | ||
494 | boost_fields[field] = boost.to_f if boost | 500 | boost_fields[field] = boost.to_f if boost |
495 | field | 501 | field |
496 | end | 502 | end |
497 | - elsif default_match != :word | ||
498 | - raise ArgumentError, "Must specify fields" | ||
499 | - else | 503 | + elsif default_match == :word |
500 | ["_all"] | 504 | ["_all"] |
505 | + elsif default_match == :phrase | ||
506 | + ["_all.phrase"] | ||
507 | + else | ||
508 | + raise ArgumentError, "Must specify fields" | ||
501 | end | 509 | end |
502 | [boost_fields, fields] | 510 | [boost_fields, fields] |
503 | end | 511 | end |