Add content autocomplete to search dropdown
This commit is contained in:
parent
4538fe2ba8
commit
fc830ea921
|
|
@ -294,12 +294,31 @@ class SearchController extends ListDiscussionsController
|
|||
return $discussions;
|
||||
}
|
||||
|
||||
protected function buildAutocompleteQuery(string $search): MatchQuery
|
||||
{
|
||||
return (new MatchQuery('title.autocomplete', $search))
|
||||
->operator('and')
|
||||
->boost(1.0);
|
||||
}
|
||||
|
||||
protected function buildAutocompleteQuery(string $search): BoolQuery
|
||||
{
|
||||
$query = BoolQuery::create();
|
||||
|
||||
// Title prefix match (stronger)
|
||||
$query->add(
|
||||
(new MatchQuery('title.autocomplete', $search))
|
||||
->operator('and')
|
||||
->boost(1.0),
|
||||
'should'
|
||||
);
|
||||
|
||||
// Content prefix match (weaker)
|
||||
$query->add(
|
||||
(new MatchQuery('content.autocomplete', $search))
|
||||
->operator('and')
|
||||
->boost(0.4),
|
||||
'should'
|
||||
);
|
||||
|
||||
$query->minimumShouldMatch(1);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the text-matching portion of the query.
|
||||
|
|
|
|||
Loading…
Reference in New Issue