@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use filtered query instead of filter in Elasticsearch

Summary:
The 'filter' works like this: Get all results matching query (all if there's no query), compute facets (if there are any) and then filter out the uninteresting results.
The 'filtered' query applies the filters when searching, not when processing results.
This is obviously not documented anywhere in the great Elasticsearch documentation.
http://stackoverflow.com/questions/14007078/performance-of-elastic-queries

We don't hit this problem very often as we usually use some query.

Test Plan: Searched for open documents using Elasticsearch, verified the sent JSON, verified results.

Reviewers: epriestley, wez

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6643

+8 -11
-2
src/applications/search/controller/PhabricatorSearchSelectController.php
··· 17 17 $user = $request->getUser(); 18 18 19 19 $query = new PhabricatorSearchQuery(); 20 - 21 20 $query_str = $request->getStr('query'); 22 - $matches = array(); 23 21 24 22 $query->setQuery($query_str); 25 23 $query->setParameter('type', $this->type);
+8 -9
src/applications/search/engine/PhabricatorSearchEngineElastic.php
··· 97 97 $spec = array(); 98 98 $filter = array(); 99 99 100 - if ($query->getQuery()) { 100 + if ($query->getQuery() != '') { 101 101 $spec[] = array( 102 102 'field' => array( 103 103 'field.corpus' => $query->getQuery(), ··· 156 156 157 157 if ($filter) { 158 158 $filter = array('filter' => array('and' => $filter)); 159 - if ($spec) { 160 - $spec = array( 161 - 'query' => array( 162 - 'filtered' => $spec + $filter, 163 - ), 164 - ); 165 - } else { 166 - $spec = $filter; 159 + if (!$spec) { 160 + $spec = array('query' => array('match_all' => new stdClass())); 167 161 } 162 + $spec = array( 163 + 'query' => array( 164 + 'filtered' => $spec + $filter, 165 + ), 166 + ); 168 167 } 169 168 170 169 if (!$query->getQuery()) {