Skip to content

Commit e30b476

Browse files
committed
Move to Elasticsearch 5
1 parent 23f7ba3 commit e30b476

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Unified search for Laravel models using Elasticsearch.",
55
"keywords": [
66
"elasticsearch",
7+
"elasticsearch 5",
78
"eloquent",
89
"laravel",
910
"unified search",
@@ -22,7 +23,7 @@
2223
"illuminate/support": "~5.2",
2324
"illuminate/database": "~5.2",
2425
"illuminate/config": "~5.2",
25-
"elasticsearch/elasticsearch": ">2.0 <2.2"
26+
"elasticsearch/elasticsearch": "~5.0"
2627
},
2728
"require-dev": {
2829
"phpunit/phpunit": "~4.2|~5.0",

src/Hunter.php

+19-5
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,25 @@ public function getSearchParams($term, array $options = [])
437437
// Check for must filters
438438
if ($filter_musts = Arr::get($options, 'filter_musts')) {
439439
foreach(array_filter($filter_musts) as $filter=>$value) {
440-
$params['body']['filter']['bool']['must'][] = [
441-
'term' => [
442-
$filter => $value,
443-
],
444-
];
440+
441+
// TODO: This sucks...fix it. Version 2 made it so that
442+
// all tags had to be present, not just some of them
443+
if (is_array($value)) {
444+
foreach($value as $k=>$v) {
445+
$params['body']['query']['bool']['must'][] = [
446+
'term' => [
447+
$filter => $v,
448+
],
449+
];
450+
}
451+
}
452+
else {
453+
$params['body']['query']['bool']['must'][] = [
454+
'term' => [
455+
$filter => $value,
456+
],
457+
];
458+
}
445459
}
446460
}
447461

0 commit comments

Comments
 (0)