本文整理汇总了PHP中Elastica\Search::addIndices方法的典型用法代码示例。如果您正苦于以下问题:PHP Search::addIndices方法的具体用法?PHP Search::addIndices怎么用?PHP Search::addIndices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elastica\Search
的用法示例。
在下文中一共展示了Search::addIndices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddIndices
/**
* @group unit
*/
public function testAddIndices()
{
$client = $this->_getClient();
$search = new Search($client);
$indices = array();
$indices[] = $client->getIndex('elastica_test1');
$indices[] = $client->getIndex('elastica_test2');
$search->addIndices($indices);
$this->assertEquals(2, count($search->getIndices()));
}
示例2: _doSearch
/**
* @param string|Query $query
* @param string|array $indices
*
* @return \Elastica\ResultSet
*/
protected function _doSearch($query, $indices = null)
{
$_results = false;
$_query = !$query instanceof Query ? new Query($query) : $query;
$_search = new Search($this->_client);
$indices = $indices ?: static::$_indices;
if (null !== $indices) {
if (!is_array($indices)) {
$indices = [$indices];
}
$_search->addIndices($indices);
}
try {
$_results = $_search->search($_query);
} catch (PartialShardFailureException $_ex) {
//Log::info( 'Partial shard failure. ' . $_ex->getMessage() . ' failed shard(s).' );
return new ResultSet($_ex->getResponse(), $_query);
} catch (\Exception $_ex) {
Log::error($_ex->getMessage());
}
return $_results;
}