Skip to content

Commit

Permalink
Search tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Torann committed Mar 1, 2017
1 parent 0336c0e commit 23f7ba3
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/Hunter.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,24 +405,26 @@ public function getSearchParams($term, array $options = [])
$params = $this->getBasicParams($options);

// Get fields option
$fields = Arr::get($options, 'field');
$fields = Arr::get($options, 'fields');

// Check for user specified fields or use default
if (is_string($fields) === false) {
if (empty($fields) === true) {
$fields = $this->config('fields');
}

// Add fields to search
if (empty($fields) === false) {
$params['body']['query']['bool']['must'][] = [
'multi_match' => [
'query' => $term,
'fields' => $fields,
],
];
}
else {
$params['body']['query']['match']['_all'][] = $term;
// Add text query if one was entered
if ($term) {
if (empty($fields) === false) {
$params['body']['query']['bool']['must'][] = [
'multi_match' => [
'query' => $term,
'fields' => $fields,
],
];
}
else {
$params['body']['query']['match']['_all'][] = $term;
}
}

// Include the locale field
Expand Down

0 comments on commit 23f7ba3

Please sign in to comment.