本文整理汇总了PHP中Elastica\Document::setType方法的典型用法代码示例。如果您正苦于以下问题:PHP Document::setType方法的具体用法?PHP Document::setType怎么用?PHP Document::setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elastica\Document
的用法示例。
在下文中一共展示了Document::setType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDocument
/**
* Convert a log message into an Elastica Document
*
* @param array $record Log message
* @return Document
*/
protected function getDocument($record)
{
$document = new Document();
$document->setData($record);
$document->setType($this->type);
$document->setIndex($this->index);
return $document;
}
示例2: getDocument
public function getDocument($record)
{
$user = $this->token->getToken()->getUser();
$record['extra']['user'] = $user->getId();
$document = new Document();
$document->setData($record);
$document->setType($this->type);
$document->setIndex($this->index);
return $document;
}
示例3: testSetIndex
/**
* @group unit
*/
public function testSetIndex()
{
$document = new Document();
$document->setIndex('index2');
$document->setType('type2');
$this->assertEquals('index2', $document->getIndex());
$this->assertEquals('type2', $document->getType());
$index = new Index($this->_getClient(), 'index');
$document->setIndex($index);
$this->assertEquals('index', $document->getIndex());
$this->assertEquals('type2', $document->getType());
}
示例4: register
/**
* {@inheritdoc}
* @see \Silex\ServiceProviderInterface::register()
*/
public function register(Application $app)
{
$app['elastic.client'] = $app->share(function () use($app) {
$config = $app['config']('elastic.connection', array());
$client = new Client($config);
return $client;
});
$app['elastic.bulk'] = $app->protect(function ($index) use($app) {
$bulk = new Bulk($app['elastic.client']);
$bulk->setIndex($index);
return $bulk;
});
$app['elastic.document'] = $app->protect(function ($type, array $data) {
$document = new Document();
$document->setType($type);
$document->setData($data);
return $document;
});
}
示例5: createDocument
/**
* @param string $id
* @param array|string $data
* @return Document
*/
public function createDocument($id = '', $data = array())
{
$document = new Document($id, $data);
$document->setType($this);
return $document;
}
示例6: testBulkType
/**
* Test bulk operations on Type.
*
* @group functional
*/
public function testBulkType()
{
$type = $this->_getClient()->getIndex('cryptocurrencies')->getType('altcoin');
$liteCoin = new Document(1, array('name' => 'litecoin'));
$nameCoin = new Document(2, array('name' => 'namecoin'));
$type->addDocuments(array($liteCoin, $nameCoin));
$this->assertEquals('litecoin', $type->getDocument(1)->get('name'));
$this->assertEquals('namecoin', $type->getDocument(2)->get('name'));
$type->updateDocuments(array(new Document(1, array('name' => 'LiteCoin')), new Document(2, array('name' => 'NameCoin'))));
$this->assertEquals('LiteCoin', $type->getDocument(1)->get('name'));
$this->assertEquals('NameCoin', $type->getDocument(2)->get('name'));
$nameCoin->setType(null);
// Make sure the type gets set properly if missing
$type->deleteDocuments(array($liteCoin, $nameCoin));
$this->setExpectedException('Elastica\\Exception\\NotFoundException');
$type->getDocument(1);
$type->getDocument(2);
}