@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.

Make it possible to configure Elasticsearch index name

Summary:
Similar to storage.default-namespace sometimes during development you'll want
to handle multiple indexes alongside one another. Rather than hardcoding the
/phabricator/ index make this exposed in new search.elastic.index setting,
defaulting to the existing "phabricator"

Test Plan:
Existing installations should be unaffected by this change. Changing the new
setting will result in new indexes being created when someone runs
`./bin/search index` again

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: 20after4, rush898, epriestley, Korvin

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

authored by

Chad Horohoe and committed by
epriestley
66a3abe0 793eced3

+16 -9
+4
src/applications/search/config/PhabricatorSearchConfigOptions.php
··· 32 32 ->setLocked(true) 33 33 ->setDescription(pht('Elastic Search host.')) 34 34 ->addExample('http://elastic.example.com:9200/', pht('Valid Setting')), 35 + $this->newOption('search.elastic.namespace', 'string', 'phabricator') 36 + ->setLocked(true) 37 + ->setDescription(pht('Elastic Search index.')) 38 + ->addExample('phabricator2', pht('Valid Setting')), 35 39 ); 36 40 } 37 41
+10 -8
src/applications/search/engine/PhabricatorSearchEngineElastic.php
··· 2 2 3 3 final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine { 4 4 private $uri; 5 + private $index; 5 6 private $timeout; 6 7 7 - public function __construct($uri) { 8 + public function __construct($uri, $index) { 8 9 $this->uri = $uri; 10 + $this->index = $index; 9 11 } 10 12 11 13 public function setTimeout($timeout) { ··· 51 53 } 52 54 53 55 $this->executeRequest( 54 - "/phabricator/{$type}/{$phid}/", 56 + "/{$type}/{$phid}/", 55 57 $spec, 56 58 $is_write = true); 57 59 } ··· 59 61 public function reconstructDocument($phid) { 60 62 $type = phid_get_type($phid); 61 63 62 - $response = $this->executeRequest("/phabricator/{$type}/{$phid}", array()); 64 + $response = $this->executeRequest("/{$type}/{$phid}", array()); 63 65 64 66 if (empty($response['exists'])) { 65 67 return null; ··· 210 212 PhabricatorSearchApplicationSearchEngine::getIndexableDocumentTypes()); 211 213 } 212 214 213 - // Don't use '/phabricator/_search' for the case that there is something 215 + // Don't use '/_search' for the case that there is something 214 216 // else in the index (for example if 'phabricator' is only an alias to 215 - // some bigger index). 216 - $uri = '/phabricator/'.implode(',', $types).'/_search'; 217 + // some bigger index). Use '/$types/_search' instead. 218 + $uri = '/'.implode(',', $types).'/_search'; 217 219 218 220 try { 219 221 $response = $this->executeRequest($uri, $this->buildSpec($query)); ··· 238 240 239 241 private function executeRequest($path, array $data, $is_write = false) { 240 242 $uri = new PhutilURI($this->uri); 243 + $uri->setPath($this->index); 244 + $uri->appendPath($path); 241 245 $data = json_encode($data); 242 - 243 - $uri->setPath($path); 244 246 245 247 $future = new HTTPSFuture($uri, $data); 246 248 if ($is_write) {
+2 -1
src/applications/search/selector/PhabricatorDefaultSearchEngineSelector.php
··· 6 6 public function newEngine() { 7 7 $elastic_host = PhabricatorEnv::getEnvConfig('search.elastic.host'); 8 8 if ($elastic_host) { 9 - return new PhabricatorSearchEngineElastic($elastic_host); 9 + $elastic_index = PhabricatorEnv::getEnvConfig('search.elastic.namespace'); 10 + return new PhabricatorSearchEngineElastic($elastic_host, $elastic_index); 10 11 } 11 12 return new PhabricatorSearchEngineMySQL(); 12 13 }