From fb9e366f9d0d0257afa23413dc220fb6deda5100 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 22 Aug 2019 13:49:35 +0200 Subject: [PATCH] wip #2956 --- src/app/Magic/Search.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/Magic/Search.php b/src/app/Magic/Search.php index 3b2b426..06a2905 100644 --- a/src/app/Magic/Search.php +++ b/src/app/Magic/Search.php @@ -189,7 +189,7 @@ class Search ]; } - public static function query($term, $limit = null) + public static function query($term, $type = null, $limit = null) { $index = config('cubist.internal_search_index'); if (null === $limit) { @@ -205,7 +205,7 @@ class Search $queryfields[] = $field . '.stemmed' . '^' . $weight; } - $res = \Elasticsearch::search(['index' => $index, + $request = ['index' => $index, 'body' => [ //'explain' => true, 'from' => 0, @@ -217,7 +217,13 @@ class Search ] ] ] - ]); + ]; + + if (null !== $type) { + $request['body']['query']['filter'] = ['term' => ['type' => $type]]; + } + + $res = \Elasticsearch::search($request); $hits = []; foreach ($res['hits']['hits'] as $hit) { -- 2.39.5