本文整理汇总了PHP中Elastica\Index::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Index::getName方法的具体用法?PHP Index::getName怎么用?PHP Index::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elastica\Index
的用法示例。
在下文中一共展示了Index::getName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: matchDoc
/**
* Match a document to percolator queries
*
* @param \Elastica\Document $doc
* @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Not implemented yet
* @return \Elastica\Response
*/
public function matchDoc(Document $doc, $query = null)
{
$path = $this->_index->getName() . '/type/_percolate';
$data = array('doc' => $doc->getData());
$response = $this->getIndex()->getClient()->request($path, Request::GET, $data);
$data = $response->getData();
return $data['matches'];
}
示例2: matchDoc
/**
* Match a document to percolator queries
*
* @param \Elastica\Document $doc
* @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the percolator queries which
* are executed.
* @param string $type
* @return array With matching registered queries.
*/
public function matchDoc(Document $doc, $query = null, $type = 'type')
{
$path = $this->_index->getName() . '/' . $type . '/_percolate';
$data = array('doc' => $doc->getData());
// Add query to filter the percolator queries which are executed.
if ($query) {
$query = Query::create($query);
$data['query'] = $query->getQuery();
}
$response = $this->getIndex()->getClient()->request($path, Request::GET, $data);
$data = $response->getData();
return $data['matches'];
}
示例3: matchDoc
/**
* Match a document to percolator queries
*
* @param \Elastica\Document $doc
* @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the data
* @return \Elastica\Response
*/
public function matchDoc(Document $doc, $query = null)
{
$path = $this->_index->getName() . '/type/_percolate';
$data = array('doc' => $doc->getData());
// Add query to filter results after percolation
if ($query) {
$query = Query::create($query);
$data['query'] = $query->getQuery();
}
$response = $this->getIndex()->getClient()->request($path, Request::GET, $data);
$data = $response->getData();
return $data['matches'];
}
示例4: matchExistingDoc
/**
* Percolating an existing document.
*
* @param string $id
* @param string $type
* @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the percolator queries which
* are executed.
* @param array $params Supports setting additional request body options to the percolate request.
* [ Percolator::EXTRA_FILTER,
* Percolator::EXTRA_QUERY,
* Percolator::EXTRA_SIZE,
* Percolator::EXTRA_TRACK_SCORES,
* Percolator::EXTRA_SORT,
* Percolator::EXTRA_FACETS,
* Percolator::EXTRA_AGGS,
* Percolator::EXTRA_HIGHLIGHT ]
*
* @return array With matching registered queries.
*/
public function matchExistingDoc($id, $type, $query = null, $params = array())
{
$id = urlencode($id);
$path = $this->_index->getName() . '/' . $type . '/' . $id . '/_percolate';
$data = array();
$this->_applyAdditionalRequestBodyOptions($params, $data);
return $this->_percolate($path, $query, $data, $params);
}
示例5: sendMapping
/**
* @param \Elastica\Index $index
* @param string $mappingName
* @param array $mappingData
*
* @return void
*/
protected function sendMapping(Index $index, $mappingName, array $mappingData)
{
$type = $index->getType($mappingName);
$this->messenger->info(sprintf('Send mapping type "%s" (index: "%s")', $mappingName, $index->getName()));
$mapping = new Mapping($type);
foreach ($mappingData as $key => $value) {
$mapping->setParam($key, $value);
}
$mapping->send();
}
示例6: testIndicesFilter
public function testIndicesFilter()
{
$filter = new Indices(new BoolNot(new Term(array("color" => "blue"))), array($this->_index1->getName()));
$filter->setNoMatchFilter(new BoolNot(new Term(array("color" => "yellow"))));
$query = new Query();
$query->setPostFilter($filter);
// search over the alias
$index = $this->_getClient()->getIndex("indices_filter");
$results = $index->search($query);
// ensure that the proper docs have been filtered out for each index
$this->assertEquals(5, $results->count());
foreach ($results->getResults() as $result) {
$data = $result->getData();
$color = $data["color"];
if ($result->getIndex() == $this->_index1->getName()) {
$this->assertNotEquals("blue", $color);
} else {
$this->assertNotEquals("yellow", $color);
}
}
}
示例7: testSnapshotAndRestore
/**
* @group functional
*/
public function testSnapshotAndRestore()
{
$repositoryName = 'testrepo';
$location = $this->_snapshotPath . 'backup2';
// register the repository
$response = $this->_snapshot->registerRepository($repositoryName, 'fs', array('location' => $location));
$this->assertTrue($response->isOk());
// create a snapshot of our test index
$snapshotName = 'test_snapshot_1';
$response = $this->_snapshot->createSnapshot($repositoryName, $snapshotName, array('indices' => $this->_index->getName()), true);
// ensure that the snapshot was created properly
$this->assertTrue($response->isOk());
$this->assertArrayHasKey('snapshot', $response->getData());
$data = $response->getData();
$this->assertContains($this->_index->getName(), $data['snapshot']['indices']);
$this->assertEquals(1, sizeof($data['snapshot']['indices']));
// only the specified index should be present
$this->assertEquals($snapshotName, $data['snapshot']['snapshot']);
// retrieve data regarding the snapshot
$response = $this->_snapshot->getSnapshot($repositoryName, $snapshotName);
$this->assertContains($this->_index->getName(), $response['indices']);
// delete our test index
$this->_index->delete();
// restore the index from our snapshot
$response = $this->_snapshot->restoreSnapshot($repositoryName, $snapshotName, array(), true);
$this->assertTrue($response->isOk());
$this->_index->refresh();
$this->_index->optimize();
// ensure that the index has been restored
$count = $this->_index->getType('test')->count();
$this->assertEquals(sizeof($this->_docs), $count);
// delete the snapshot
$response = $this->_snapshot->deleteSnapshot($repositoryName, $snapshotName);
$this->assertTrue($response->isOk());
// ensure that the snapshot has been deleted
$this->setExpectedException('Elastica\\Exception\\NotFoundException');
$this->_snapshot->getSnapshot($repositoryName, $snapshotName);
}
示例8: testSnapshotAndRestore
public function testSnapshotAndRestore()
{
$repositoryName = "test_repository";
$location = "/tmp/{$repositoryName}";
// register the repository
$response = $this->_snapshot->registerRepository($repositoryName, "fs", array("location" => $location));
$this->assertTrue($response->isOk());
// create a snapshot of our test index
$snapshotName = "test_snapshot_1";
$response = $this->_snapshot->createSnapshot($repositoryName, $snapshotName, array("indices" => $this->_index->getName()), true);
// ensure that the snapshot was created properly
$this->assertTrue($response->isOk());
$this->assertArrayHasKey("snapshot", $response->getData());
$data = $response->getData();
$this->assertContains($this->_index->getName(), $data["snapshot"]["indices"]);
$this->assertEquals(1, sizeof($data["snapshot"]["indices"]));
// only the specified index should be present
$this->assertEquals($snapshotName, $data["snapshot"]["snapshot"]);
// retrieve data regarding the snapshot
$response = $this->_snapshot->getSnapshot($repositoryName, $snapshotName);
$this->assertContains($this->_index->getName(), $response["indices"]);
// delete our test index
$this->_index->delete();
// restore the index from our snapshot
$response = $this->_snapshot->restoreSnapshot($repositoryName, $snapshotName, array(), true);
$this->assertTrue($response->isOk());
$this->_index->refresh();
$this->_index->optimize();
// ensure that the index has been restored
$count = $this->_index->getType("test")->count();
$this->assertEquals(sizeof($this->_docs), $count);
// delete the snapshot
$response = $this->_snapshot->deleteSnapshot($repositoryName, $snapshotName);
$this->assertTrue($response->isOk());
// ensure that the snapshot has been deleted
$this->setExpectedException('Elastica\\Exception\\NotFoundException');
$this->_snapshot->getSnapshot($repositoryName, $snapshotName);
}
示例9: testToArrayFromReference
/**
* @group unit
*/
public function testToArrayFromReference()
{
$client = $this->_getClient();
$index = new Index($client, 'test');
$type = new Type($index, 'helloworld');
$field = 'image';
$query = new Image();
$query->setFieldFeature($field, 'CEDD');
$query->setFieldHash($field, 'BIT_SAMPLING');
$query->setFieldBoost($field, 100);
$query->setImageByReference($field, $index->getName(), $type->getName(), 10);
$jsonString = '{"image":{"image":{"feature":"CEDD","hash":"BIT_SAMPLING","boost":100,"index":"test","type":"helloworld","id":10,"path":"image"}}}';
$this->assertEquals($jsonString, json_encode($query->toArray()));
}
示例10: getHealth
/**
* Get health information about the index
* @return array Response data array
*/
private function getHealth()
{
while (true) {
$indexName = $this->index->getName();
$path = "_cluster/health/{$indexName}";
$response = $this->index->getClient()->request($path);
if ($response->hasError()) {
$this->error('Error fetching index health but going to retry. Message: ' . $response->getError());
sleep(1);
continue;
}
return $response->getData();
}
}
示例11: __construct
/**
* @param Index $index
* @param \ElasticaConnection $connection
* @param Type[] $types
* @param Type[] $oldTypes
* @param int $shardCount
* @param string $replicaCount
* @param int $connectionTimeout
* @param array $mergeSettings
* @param array $mappingConfig
* @param Maintenance $out
*/
public function __construct(Index $index, \ElasticaConnection $connection, array $types, array $oldTypes, $shardCount, $replicaCount, $connectionTimeout, array $mergeSettings, array $mappingConfig, Maintenance $out = null)
{
// @todo: this constructor has too many arguments - refactor!
$this->index = $index;
$this->client = $this->index->getClient();
$this->specificIndexName = $this->index->getName();
$this->connection = $connection;
$this->types = $types;
$this->oldTypes = $oldTypes;
$this->shardCount = $shardCount;
$this->replicaCount = $replicaCount;
$this->connectionTimeout = $connectionTimeout;
$this->mergeSettings = $mergeSettings;
$this->mappingConfig = $mappingConfig;
$this->out = $out;
}
示例12: _waitForAllocation
protected function _waitForAllocation(Index $index)
{
do {
$state = $index->getClient()->getCluster()->getState();
$indexState = $state['routing_table']['indices'][$index->getName()];
$allocated = true;
foreach ($indexState['shards'] as $shard) {
if ($shard[0]['state'] != 'STARTED') {
$allocated = false;
}
}
} while (!$allocated);
}
示例13: __construct
/**
* Constructor.
*
* @param array $indexesByName
* @param Index $defaultIndex
*/
public function __construct(array $indexesByName, Index $defaultIndex)
{
$this->indexesByName = $indexesByName;
$this->defaultIndexName = $defaultIndex->getName();
}
示例14: matchExistingDoc
/**
* Percolating an existing document
*
* @param string $id
* @param string $type
* @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the percolator queries which
* are executed.
* @param array $params
* @return array With matching registered queries.
*/
public function matchExistingDoc($id, $type, $query = null, $params = array())
{
$id = urlencode($id);
$path = $this->_index->getName() . '/' . $type . '/' . $id . '/_percolate';
return $this->_percolate($path, $query, array(), $params);
}