File tree 1 file changed +15
-13
lines changed
1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -405,24 +405,26 @@ public function getSearchParams($term, array $options = [])
405
405
$ params = $ this ->getBasicParams ($ options );
406
406
407
407
// Get fields option
408
- $ fields = Arr::get ($ options , 'field ' );
408
+ $ fields = Arr::get ($ options , 'fields ' );
409
409
410
410
// Check for user specified fields or use default
411
- if (is_string ($ fields ) === false ) {
411
+ if (empty ($ fields ) === true ) {
412
412
$ fields = $ this ->config ('fields ' );
413
413
}
414
414
415
- // Add fields to search
416
- if (empty ($ fields ) === false ) {
417
- $ params ['body ' ]['query ' ]['bool ' ]['must ' ][] = [
418
- 'multi_match ' => [
419
- 'query ' => $ term ,
420
- 'fields ' => $ fields ,
421
- ],
422
- ];
423
- }
424
- else {
425
- $ params ['body ' ]['query ' ]['match ' ]['_all ' ][] = $ term ;
415
+ // Add text query if one was entered
416
+ if ($ term ) {
417
+ if (empty ($ fields ) === false ) {
418
+ $ params ['body ' ]['query ' ]['bool ' ]['must ' ][] = [
419
+ 'multi_match ' => [
420
+ 'query ' => $ term ,
421
+ 'fields ' => $ fields ,
422
+ ],
423
+ ];
424
+ }
425
+ else {
426
+ $ params ['body ' ]['query ' ]['match ' ]['_all ' ][] = $ term ;
427
+ }
426
428
}
427
429
428
430
// Include the locale field
You can’t perform that action at this time.
0 commit comments