diff --git a/Blacklight/ManticoreSearch.php b/Blacklight/ManticoreSearch.php index 093b4b24a..d82aed7da 100644 --- a/Blacklight/ManticoreSearch.php +++ b/Blacklight/ManticoreSearch.php @@ -186,13 +186,14 @@ class ManticoreSearch { $resultId = []; $resultData = []; - $query = $this->search->setIndex($rt_index)->maxMatches(10000)->option('ranker', 'sph04')->option('sort_method', 'pq')->limit(10000)->sort('id', 'desc')->stripBadUtf8(true)->trackScores(true); + $query = $this->search->setIndex($rt_index)->option('boolean_simplify', 1)->option('ranker', 'sph04')->option('sort_method', 'pq')->maxMatches(10000)->limit(10000)->sort('id', 'desc')->stripBadUtf8(true)->trackScores(true); if (! empty($searchArray)) { foreach ($searchArray as $key => $value) { - $query->match(['query' => $value, 'operator' => 'and', 'column' => $key]); + $query->search('@@relaxed @'.$key.' '.$value); } } elseif (! empty($searchString)) { - $query->match(['query' => $searchString, 'column' => $column, 'operator' => 'and']); + $searchColumns = ! empty($column) ? '@'.implode('', $column) : ''; + $query->search('@@relaxed'.$searchColumns.' '.$searchString); } else { return []; } diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 3d5e70fa9..b65daf68a 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -43,17 +43,19 @@ class SearchController extends BasePageController $searchString = []; switch (true) { case $request->filled('subject'): - $searchString['searchname'] = (string) $request->input('subject'); + $searchString['searchname'] = (string) $request->input('subject') ?? []; $this->smarty->assign('subject', $searchString['searchname']); break; case $request->filled('id'): - $searchString['searchname'] = (string) $request->input('id'); + $searchString['searchname'] = (string) $request->input('id') ?? []; $this->smarty->assign('id', $searchString['searchname']); break; case $request->filled('search'): - $searchString['searchname'] = (string) $request->input('search'); + $searchString['searchname'] = (string) $request->input('search') ?? []; $this->smarty->assign('search', $searchString['searchname']); break; + default: + $searchString['searchname'] = ''; } $categoryID[] = -1;