mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
T7827: Boost Elasticsearch results on title match.
Summary: If match is found on document title, boost result. Test Plan: - Setup phabricator with elasticsearch. - Index documents with `bin/search index --all` - Use search and expect query matching titles appear on the top of results list. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: WikiChad, Korvin, epriestley Maniphest Tasks: T7827 Differential Revision: https://secure.phabricator.com/D12432
This commit is contained in:
parent
54b513286c
commit
3a17220ce3
1 changed files with 11 additions and 0 deletions
|
@ -93,6 +93,7 @@ final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
|
|||
private function buildSpec(PhabricatorSavedQuery $query) {
|
||||
$spec = array();
|
||||
$filter = array();
|
||||
$title_spec = array();
|
||||
|
||||
if (strlen($query->getParameter('query'))) {
|
||||
$spec[] = array(
|
||||
|
@ -101,6 +102,13 @@ final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
|
|||
'fields' => array( 'field.corpus' ),
|
||||
),
|
||||
);
|
||||
|
||||
$title_spec = array(
|
||||
'simple_query_string' => array(
|
||||
'query' => $query->getParameter('query'),
|
||||
'fields' => array('title'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$exclude = $query->getParameter('exclude');
|
||||
|
@ -174,6 +182,9 @@ final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
|
|||
|
||||
if ($spec) {
|
||||
$spec = array('query' => array('bool' => array('must' => $spec)));
|
||||
if ($title_spec) {
|
||||
$spec['query']['bool']['should'] = $title_spec;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filter) {
|
||||
|
|
Loading…
Reference in a new issue