本文整理匯總了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);
}