/**
  * Checks if all the specified indexes are available for writes. They might
  * not currently allow writes during procedures like reindexing or rolling
  * restarts.
  *
  * @param string[] $indexes List of index names to check for availability.
  * @param bool $areIndexesFullyQualified Set to true if the provided $indexes are
  *  already fully qualified elasticsearch index names.
  * @return bool
  */
 public function areIndexesAvailableForWrites(array $indexes, $areIndexesFullyQualified = false)
 {
     if (count($indexes) === 0) {
         return true;
     }
     if (!$areIndexesFullyQualified) {
         $indexes = $this->indexesToIndexNames($indexes);
     }
     $ids = new \Elastica\Query\Ids(null, $indexes);
     $ids->addId(self::ALL_INDEXES_FROZEN_NAME);
     $resp = $this->connection->getFrozenIndexNameType()->search($ids);
     if ($resp->count() === 0) {
         $this->log->debug("Allowed writes to " . implode(',', $indexes));
         return true;
     } else {
         $this->log->debug("Denied writes to " . implode(',', $indexes));
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * @group unit
  */
 public function testConstruct()
 {
     $filter = new \Elastica\Query\Ids();
     $filter->setIds(array(1));
     $query = new ConstantScore($filter);
     $expectedArray = array('constant_score' => array('filter' => $filter->toArray()));
     $this->assertEquals($expectedArray, $query->toArray());
 }