diff options
| author | Yuriy Andamasov <yuriy@andamasov.com> | 2026-05-23 14:23:39 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-23 14:23:39 +0300 |
| commit | b630182d8e0509d4a807623dd0b3976c81f77f39 (patch) | |
| tree | 8d7d90a03b09cc21f0d80f7038cc1da88779dbb9 /src/engine/VyOSElasticModernFulltextStorageEngine.php | |
| parent | c1a972d45d60f5d721156d7dfb7a958f2e7b9abc (diff) | |
| parent | f945e302f79086c6ea99bd45d414fe6bccefb9d4 (diff) | |
| download | phorge-elasticsearch-modern-b630182d8e0509d4a807623dd0b3976c81f77f39.tar.gz phorge-elasticsearch-modern-b630182d8e0509d4a807623dd0b3976c81f77f39.zip | |
Merge pull request #9 from vyos/task/e6-setservice
E6: Wire setService() + identifier + host glue
Diffstat (limited to 'src/engine/VyOSElasticModernFulltextStorageEngine.php')
| -rw-r--r-- | src/engine/VyOSElasticModernFulltextStorageEngine.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/engine/VyOSElasticModernFulltextStorageEngine.php b/src/engine/VyOSElasticModernFulltextStorageEngine.php index fe88adc..42e2fd6 100644 --- a/src/engine/VyOSElasticModernFulltextStorageEngine.php +++ b/src/engine/VyOSElasticModernFulltextStorageEngine.php @@ -8,6 +8,46 @@ abstract class VyOSElasticModernFulltextStorageEngine extends PhabricatorFulltextStorageEngine { private $version = null; + private $index; + + public function setService(PhabricatorSearchService $service) { + $this->service = $service; // inherited protected property + $config = $service->getConfig(); + $index = idx($config, 'path', '/phabricator'); + $normalized = trim($index, '/'); + if ($normalized === '') { + throw new Exception( + pht( + 'Invalid index path "%s" in cluster.search config: '. + 'path must contain at least one non-slash character.', + $index)); + } + $this->index = $normalized; + $this->setVersion(idx($config, 'version', 7)); + return $this; + } + + public function getTimestampField() { + return 'lastModified'; + } + + public function getTextFieldType() { + return 'text'; + } + + public function getHostForRead() { + return $this->getService()->getAnyHostForRole('read'); + } + + public function getHostForWrite() { + return $this->getService()->getAnyHostForRole('write'); + } + + public function getTypeConstants($class) { + $relationship_class = new ReflectionClass($class); + $typeconstants = $relationship_class->getConstants(); + return array_unique(array_values($typeconstants)); + } public function setVersion($version) { $version = (int)$version; |
