Page MenuHomePhabricator

D9798.id23739.diff
No OneTemporary

D9798.id23739.diff

diff --git a/src/applications/search/config/PhabricatorSearchConfigOptions.php b/src/applications/search/config/PhabricatorSearchConfigOptions.php
--- a/src/applications/search/config/PhabricatorSearchConfigOptions.php
+++ b/src/applications/search/config/PhabricatorSearchConfigOptions.php
@@ -32,6 +32,10 @@
->setLocked(true)
->setDescription(pht('Elastic Search host.'))
->addExample('http://elastic.example.com:9200/', pht('Valid Setting')),
+ $this->newOption('search.elastic.namespace', 'string', 'phabricator')
+ ->setLocked(true)
+ ->setDescription(pht('Elastic Search index.'))
+ ->addExample('phabricator2', pht('Valid Setting')),
);
}
diff --git a/src/applications/search/engine/PhabricatorSearchEngineElastic.php b/src/applications/search/engine/PhabricatorSearchEngineElastic.php
--- a/src/applications/search/engine/PhabricatorSearchEngineElastic.php
+++ b/src/applications/search/engine/PhabricatorSearchEngineElastic.php
@@ -2,10 +2,12 @@
final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
private $uri;
+ private $index;
private $timeout;
- public function __construct($uri) {
+ public function __construct($uri, $index) {
$this->uri = $uri;
+ $this->index = $index;
}
public function setTimeout($timeout) {
@@ -51,7 +53,7 @@
}
$this->executeRequest(
- "/phabricator/{$type}/{$phid}/",
+ "/{$type}/{$phid}/",
$spec,
$is_write = true);
}
@@ -59,7 +61,7 @@
public function reconstructDocument($phid) {
$type = phid_get_type($phid);
- $response = $this->executeRequest("/phabricator/{$type}/{$phid}", array());
+ $response = $this->executeRequest("/{$type}/{$phid}", array());
if (empty($response['exists'])) {
return null;
@@ -210,10 +212,10 @@
PhabricatorSearchApplicationSearchEngine::getIndexableDocumentTypes());
}
- // Don't use '/phabricator/_search' for the case that there is something
+ // Don't use '/_search' for the case that there is something
// else in the index (for example if 'phabricator' is only an alias to
- // some bigger index).
- $uri = '/phabricator/'.implode(',', $types).'/_search';
+ // some bigger index). Use '/$types/_search' instead.
+ $uri = '/'.implode(',', $types).'/_search';
try {
$response = $this->executeRequest($uri, $this->buildSpec($query));
@@ -238,10 +240,10 @@
private function executeRequest($path, array $data, $is_write = false) {
$uri = new PhutilURI($this->uri);
+ $uri->setPath($this->index);
+ $uri->appendPath($path);
$data = json_encode($data);
- $uri->setPath($path);
-
$future = new HTTPSFuture($uri, $data);
if ($is_write) {
$future->setMethod('PUT');
diff --git a/src/applications/search/selector/PhabricatorDefaultSearchEngineSelector.php b/src/applications/search/selector/PhabricatorDefaultSearchEngineSelector.php
--- a/src/applications/search/selector/PhabricatorDefaultSearchEngineSelector.php
+++ b/src/applications/search/selector/PhabricatorDefaultSearchEngineSelector.php
@@ -6,7 +6,8 @@
public function newEngine() {
$elastic_host = PhabricatorEnv::getEnvConfig('search.elastic.host');
if ($elastic_host) {
- return new PhabricatorSearchEngineElastic($elastic_host);
+ $elastic_index = PhabricatorEnv::getEnvConfig('search.elastic.namespace');
+ return new PhabricatorSearchEngineElastic($elastic_host, $elastic_index);
}
return new PhabricatorSearchEngineMySQL();
}

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 3:53 AM (6 h, 47 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6923539
Default Alt Text
D9798.id23739.diff (3 KB)

Event Timeline