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