Pass URI to Elastic engine from outside
Summary: We need to generate the URI dynamically. This code is also generally better. Test Plan: Created custom search selector passing the custom URI to engine. Reviewers: epriestley, edward Reviewed By: epriestley CC: aran, Koolvin Differential Revision: https://secure.phabricator.com/D2655
This commit is contained in:
@@ -17,6 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
|
final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
|
||||||
|
private $uri;
|
||||||
|
|
||||||
|
public function __construct($uri) {
|
||||||
|
$this->uri = $uri;
|
||||||
|
}
|
||||||
|
|
||||||
public function reindexAbstractDocument(
|
public function reindexAbstractDocument(
|
||||||
PhabricatorSearchAbstractDocument $doc) {
|
PhabricatorSearchAbstractDocument $doc) {
|
||||||
@@ -183,8 +188,7 @@ final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function executeRequest($path, array $data, $is_write = false) {
|
private function executeRequest($path, array $data, $is_write = false) {
|
||||||
$uri = PhabricatorEnv::getEnvConfig('search.elastic.host');
|
$uri = new PhutilURI($this->uri);
|
||||||
$uri = new PhutilURI($uri);
|
|
||||||
$data = json_encode($data);
|
$data = json_encode($data);
|
||||||
|
|
||||||
$uri->setPath($path);
|
$uri->setPath($path);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 Facebook, Inc.
|
* Copyright 2012 Facebook, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -23,8 +23,9 @@ final class PhabricatorDefaultSearchEngineSelector
|
|||||||
extends PhabricatorSearchEngineSelector {
|
extends PhabricatorSearchEngineSelector {
|
||||||
|
|
||||||
public function newEngine() {
|
public function newEngine() {
|
||||||
if (PhabricatorEnv::getEnvConfig('search.elastic.host')) {
|
$elastic_host = PhabricatorEnv::getEnvConfig('search.elastic.host');
|
||||||
return new PhabricatorSearchEngineElastic();
|
if ($elastic_host) {
|
||||||
|
return new PhabricatorSearchEngineElastic($elastic_host);
|
||||||
}
|
}
|
||||||
return new PhabricatorSearchEngineMySQL();
|
return new PhabricatorSearchEngineMySQL();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user