本文整理汇总了PHP中Elastica\Index::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP Index::getType方法的具体用法?PHP Index::getType怎么用?PHP Index::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elastica\Index
的用法示例。
在下文中一共展示了Index::getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
/**
* До любых других действий
*/
public function initialize()
{
$currentActionName = $this->dispatcher->getActiveMethod();
$annotations = $this->annotations->getMethod(self::class, $currentActionName);
if ($annotations->has('actionInfo')) {
$annotation = $annotations->get('actionInfo');
$actionTitle = $annotation->getNamedArgument('name');
$this->log->info('Запустили: {actionTitle}', ['actionTitle' => $actionTitle]);
} else {
$currentTaskName = $this->dispatcher->getTaskName();
$this->log->info('Запустили: {currentTaskName}::{currentActionName}', ['currentTaskName' => $currentTaskName, 'currentActionName' => $currentActionName]);
}
$this->indexName = $this->dispatcher->getParam('index', 'string', false);
$this->typeName = $this->dispatcher->getParam('type', 'string', false);
if (!$this->indexName) {
$this->log->error('Указание индекса является обязательным параметром');
die;
}
$this->sizePerShard = $this->dispatcher->getParam('sizePerShard', 'int', false) ?: $this->sizePerShard;
$this->elasticsearchHost = $this->dispatcher->getParam('host', 'string', false) ?: $this->elasticsearchHost;
$this->elasticsearchPort = $this->dispatcher->getParam('port', 'int', false) ?: $this->elasticsearchPort;
$connectParams = ['host' => $this->elasticsearchHost, 'port' => $this->elasticsearchPort];
$this->client = new Client($connectParams);
try {
$this->client->getStatus();
} catch (\Elastica\Exception\Connection\HttpException $e) {
$context = ['host' => $this->elasticsearchHost, 'port' => $this->elasticsearchPort];
$this->log->error('Подключение к серверу elasticsearch отсутствует: http://{host}:{port}', $context);
die;
}
$this->elasticaIndex = $this->client->getIndex($this->indexName);
$this->elasticaType = $this->elasticaIndex->getType($this->typeName);
}
示例2: write
/**
* @param array $dataSet
*
* @return bool
*/
public function write(array $dataSet)
{
$type = $this->index->getType($this->type);
$type->updateDocuments($this->createDocuments($dataSet));
$response = $type->getIndex()->refresh();
return $response->isOk();
}
示例3: testGetDocument
public function testGetDocument()
{
$type = self::$index->getType('message');
$document = $type->getDocument(1);
$message = $this->marshaler->unmarshal($document);
$this->assertTrue($this->message->equals($message));
}
示例4: setUp
protected function setUp()
{
parent::setUp();
$this->_index = $this->_createIndex("simple_query_string_test");
$docs = array(new Document(1, array('make' => 'Gibson', 'model' => 'Les Paul')), new Document(2, array('make' => 'Gibson', 'model' => 'SG Standard')), new Document(3, array('make' => 'Gibson', 'model' => 'SG Supreme')), new Document(4, array('make' => 'Gibson', 'model' => 'SG Faded')), new Document(5, array('make' => 'Fender', 'model' => 'Stratocaster')));
$this->_index->getType("guitars")->addDocuments($docs);
$this->_index->refresh();
}
示例5: setUp
protected function setUp()
{
parent::setUp();
$this->_index = $this->_createIndex("query");
$docs = array(new Document("1", array("color" => "green", "make" => "ford")), new Document("2", array("color" => "blue", "make" => "volvo")), new Document("3", array("color" => "red", "make" => "ford")), new Document("4", array("color" => "green", "make" => "renault")));
$this->_index->getType("test")->addDocuments($docs);
$this->_index->refresh();
}
示例6: createMapping
public function createMapping()
{
// Define mapping
$mapping = new \Elastica\Type\Mapping();
$mapping->setType($this->trackIndex->getType('track'));
// Set mapping
$mapping->setProperties(['id' => ['type' => 'integer', 'include_in_all' => false], 'album' => ['type' => 'object', 'properties' => ['id' => ['type' => 'integer', 'include_in_all' => true], 'title' => ['type' => 'string', 'include_in_all' => true]]], 'name' => ['type' => 'string', 'include_in_all' => true], 'name_not_analyzed' => ['type' => 'string', "index" => "not_analyzed"], 'playList' => ['type' => 'nested', 'properties' => ['id' => ['type' => 'integer', 'include_in_all' => true], 'name' => ['type' => 'string', 'include_in_all' => true]]], 'genre' => ['type' => 'object', 'properties' => ['id' => ['type' => 'integer', 'include_in_all' => true], 'name' => ['type' => 'string', 'include_in_all' => true]]], 'mediaType' => ['type' => 'object', 'properties' => ['id' => ['type' => 'integer', 'include_in_all' => true], 'name' => ['type' => 'string', 'include_in_all' => true]]], 'composer' => ['type' => 'string', 'include_in_all' => true]]);
// Send mapping to type
$mapping->send();
}
开发者ID:slaparra,项目名称:Training-Elastic-Search-Symfony,代码行数:10,代码来源:CreateElasticSearchTrackIndexCommand.php
示例7: setUp
protected function setUp()
{
parent::setUp();
$this->index = $this->_createIndex('test_functionscore');
$this->type = $this->index->getType('test');
$this->type->setMapping(array('name' => array('type' => 'string', 'index' => 'not_analyzed'), 'location' => array('type' => 'geo_point'), 'price' => array('type' => 'float')));
$this->type->addDocument(new Document(1, array('name' => "Mr. Frostie's", 'location' => array('lat' => 32.799605, 'lon' => -117.243027), 'price' => 4.5)));
$this->type->addDocument(new Document(2, array('name' => "Miller's Field", 'location' => array('lat' => 32.795964, 'lon' => -117.255028), 'price' => 9.5)));
$this->index->refresh();
}
示例8: setUp
protected function setUp()
{
parent::setUp();
$this->index = $this->_createIndex('test_boostingquery');
$this->type = $this->index->getType('test');
$this->type->setMapping(array('name' => array('type' => 'string', 'index' => 'analyzed'), 'price' => array('type' => 'float')));
$this->sampleData = array(array("name" => "Vital Lama", "price" => 5.2), array("name" => "Vital Match", "price" => 2.1), array("name" => "Mercury Vital", "price" => 7.5), array("name" => "Fist Mercury", "price" => 3.8), array("name" => "Lama Vital 2nd", "price" => 3.2));
foreach ($this->sampleData as $key => $value) {
$this->type->addDocument(new Document($key, $value));
}
$this->index->refresh();
}
示例9: setUp
protected function setUp()
{
parent::setUp();
$this->_index1 = $this->_createIndex('indices_filter_1');
$this->_index2 = $this->_createIndex('indices_filter_2');
$this->_index1->addAlias("indices_filter");
$this->_index2->addAlias("indices_filter");
$docs = array(new Document("1", array("color" => "blue")), new Document("2", array("color" => "green")), new Document("3", array("color" => "blue")), new Document("4", array("color" => "yellow")));
$this->_index1->getType("test")->addDocuments($docs);
$this->_index2->getType("test")->addDocuments($docs);
$this->_index1->refresh();
$this->_index2->refresh();
}
示例10: setUp
protected function setUp()
{
parent::setUp();
$this->_index = $this->_createIndex('test_suggest_phrase');
$docs = array();
$docs[] = new Document(1, array('text' => 'Github is pretty cool'));
$docs[] = new Document(2, array('text' => 'Elasticsearch is bonsai cool'));
$docs[] = new Document(3, array('text' => 'This is a test phrase'));
$docs[] = new Document(4, array('text' => 'Another sentence for testing'));
$docs[] = new Document(5, array('text' => 'Some more words here'));
$type = $this->_index->getType(self::TEST_TYPE);
$type->addDocuments($docs);
$this->_index->refresh();
}
示例11: setUp
protected function setUp()
{
parent::setUp();
$this->_index = $this->_createIndex('test_suggest');
$docs = array();
$docs[] = new Document(1, array('id' => 1, 'text' => 'GitHub'));
$docs[] = new Document(2, array('id' => 1, 'text' => 'Elastic'));
$docs[] = new Document(3, array('id' => 1, 'text' => 'Search'));
$docs[] = new Document(4, array('id' => 1, 'text' => 'Food'));
$docs[] = new Document(5, array('id' => 1, 'text' => 'Flood'));
$docs[] = new Document(6, array('id' => 1, 'text' => 'Folks'));
$type = $this->_index->getType(self::TEST_TYPE);
$type->addDocuments($docs);
$this->_index->refresh();
}
示例12: getType
/**
* Get an elasticsearch type from its index.
*
* @param string $type
* @return \Elastica\Type
*/
protected function getType($type)
{
if (!isset($this->index)) {
$this->index = $this->newIndex();
}
return $this->index->getType($type);
}
示例13: getType
public function getType($type)
{
if (isset($this->typeCache[$type])) {
return $this->typeCache[$type];
}
return $this->typeCache[$type] = parent::getType($type);
}
示例14: delete
/**
* @param array $dataSet
*
* @throws \Spryker\Zed\Collector\Business\Exporter\Exception\InvalidDataSetException
*
* @return bool
*/
public function delete(array $dataSet)
{
if ($this->hasIntegerKeys($dataSet)) {
throw new InvalidDataSetException();
}
try {
$documents = [];
foreach ($dataSet as $key => $value) {
$documents[] = $this->index->getType($this->type)->getDocument($key);
}
$response = $this->index->deleteDocuments($documents);
$this->index->flush(true);
return $response->isOk();
} catch (\Exception $exception) {
return true;
}
}
示例15: 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();
}