];
}
- 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) {
$queryfields[] = $field . '.stemmed' . '^' . $weight;
}
- $res = \Elasticsearch::search(['index' => $index,
+ $request = ['index' => $index,
'body' => [
//'explain' => true,
'from' => 0,
]
]
]
- ]);
+ ];
+
+ if (null !== $type) {
+ $request['body']['query']['filter'] = ['term' => ['type' => $type]];
+ }
+
+ $res = \Elasticsearch::search($request);
$hits = [];
foreach ($res['hits']['hits'] as $hit) {