]> _ Git - cubist_cms-back.git/commitdiff
wip #2956
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 22 Aug 2019 11:49:35 +0000 (13:49 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 22 Aug 2019 11:49:35 +0000 (13:49 +0200)
src/app/Magic/Search.php

index 3b2b4269349245f53c75c6544bb1c0e837b84d8a..06a2905082558d2d530101dbde0acd0aa1f1019d 100644 (file)
@@ -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) {