addIndices() public method

Add array of indices at once.
public addIndices ( array $indices = [] )
$indices array
Ejemplo n.º 1
0
 /**
  * @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()));
 }
Ejemplo n.º 2
0
 /**
  * @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;
 }