protected function getIndex()
 {
     $connection = new Search_Elastic_Connection('http://localhost:9200');
     $status = $connection->getStatus();
     if (!$status->ok) {
         $this->markTestSkipped('ElasticSearch needs to be available on localhost:9200 for the test to run.');
     }
     return new Search_Elastic_Index($connection, 'test_index');
 }
示例#2
0
 function testObtainStatus()
 {
     $connection = new Search_Elastic_Connection('http://localhost:9200');
     $status = $connection->getStatus();
     if (!$status->ok) {
         $this->markTestSkipped('ElasticSearch needs to be available on localhost:9200 for the test to run.');
     }
     $this->assertEquals(200, $status->status);
 }
示例#3
0
 function setUp()
 {
     $connection = new Search_Elastic_Connection('http://localhost:9200');
     $status = $connection->getStatus();
     if (!$status->ok) {
         $this->markTestSkipped('Elasticsearch needs to be available on localhost:9200 for the test to run.');
     }
     $this->connection = $connection;
 }
示例#4
0
 function setUp()
 {
     $connection = new Search_Elastic_Connection('http://localhost:9200');
     $connection->startBulk(100);
     $status = $connection->getStatus();
     if (!$status->ok) {
         $this->markTestSkipped('ElasticSearch needs to be available on localhost:9200 for the test to run.');
     }
     $this->index = new Search_Elastic_Index($connection, 'test_index');
     $this->index->destroy();
 }
示例#5
0
 function setUp()
 {
     $connection = new Search_Elastic_Connection('http://localhost:9200');
     $status = $connection->getStatus();
     if (!$status->ok) {
         $this->markTestSkipped('Elasticsearch needs to be available on localhost:9200 for the test to run.');
     }
     if (version_compare($status->version->number, '1.1.0') < 0) {
         $this->markTestSkipped('Elasticsearch 1.1+ required');
     }
     $this->index = new Search_Elastic_Index($connection, 'test_index');
     $this->index->destroy();
     $factory = $this->index->getTypeFactory();
     $this->index->addDocument(array('object_type' => $factory->identifier('wiki page'), 'object_id' => $factory->identifier('HomePage'), 'contents' => $factory->plaintext('Hello World')));
 }
示例#6
0
 function setUp()
 {
     $connection = new Search_Elastic_Connection('http://localhost:9200');
     $status = $connection->getStatus();
     if (!$status->ok) {
         $this->markTestSkipped('ElasticSearch needs to be available on localhost:9200 for the test to run.');
     }
     $this->indexA = new Search_Elastic_Index($connection, 'test_index_a');
     $this->indexA->destroy();
     $factory = $this->indexA->getTypeFactory();
     $this->indexA->addDocument(array('object_type' => $factory->identifier('wiki page'), 'object_id' => $factory->identifier('PageA'), 'contents' => $factory->plaintext('Hello World A'), 'url' => $factory->identifier('PageA')));
     $this->indexB = new Search_Elastic_Index($connection, 'test_index_b_foo');
     $this->indexB->destroy();
     $factory = $this->indexB->getTypeFactory();
     $this->indexB->addDocument(array('object_type' => $factory->identifier('wiki page'), 'object_id' => $factory->identifier('PageB'), 'contents' => $factory->plaintext('Hello World B'), 'url' => $factory->identifier('PageB')));
     $this->indexC = new Search_Elastic_Index($connection, 'test_index_c');
     $this->indexC->destroy();
     $factory = $this->indexC->getTypeFactory();
     $this->indexC->addDocument(array('object_type' => $factory->identifier('wiki page'), 'object_id' => $factory->identifier('PageB'), 'contents' => $factory->plaintext('Hello World C'), 'url' => $factory->identifier('/PageC')));
     $connection->refresh('*');
     $connection->assignAlias('test_index_b', 'test_index_b_foo');
 }
示例#7
0
 private function getElasticConnection($useMasterOnly)
 {
     global $prefs;
     static $connections = [];
     $target = $prefs['unified_elastic_url'];
     if (!$useMasterOnly && $prefs['federated_elastic_url']) {
         $target = $prefs['federated_elastic_url'];
     }
     if (!empty($connections[$target])) {
         return $connections[$target];
     }
     $connection = new Search_Elastic_Connection($target);
     $connection->startBulk();
     $connection->persistDirty(TikiLib::events());
     $connections[$target] = $connection;
     return $connection;
 }
示例#8
0
 private function getElasticConnection()
 {
     global $prefs;
     $connection = new Search_Elastic_Connection($prefs['unified_elastic_url']);
     $connection->startBulk();
     return $connection;
 }
示例#9
0
 public function createIndex($location, $index, $type, array $mapping)
 {
     $connection = new Search_Elastic_Connection($location);
     $connection->mapping($index, $type, $mapping);
 }