{@inheritdoc}
@throws \Flowpack\ElasticSearch\Exception
321191
public function bulk(Index $index, $request): array
    {
        if (is_array($request)) {
            $request = json_encode($request);
        }

        // Bulk request MUST end with line return
        $request = trim($request) . "\n";

        $response = $index->request('POST', '/_bulk', [], $request)->getOriginalResponse()->getContent();

        return array_map('json_decode', explode("\n", $response));
    }
56205
public function getIndexConfigurator()
    {
        static $indexConfigurator;

        if (! $indexConfigurator) {
            if (! isset($this->indexConfigurator) || empty($this->indexConfigurator)) {
                throw new Exception(sprintf(
                    'An index configurator for the %s model is not specified.',
                    __CLASS__
                ));
            }

            $indexConfiguratorClass = $this->indexConfigurator;
            $indexConfigurator = new $indexConfiguratorClass;
        }

        return $indexConfigurator;
    }
1346369
public function updateIndexAlias(): void
    {
        $aliasName = $this->searchClient->getIndexName(); // The alias name is the unprefixed index name
        if ($this->getIndexName() === $aliasName) {
            throw new Exception('UpdateIndexAlias is only allowed to be called when $this->setIndexNamePostfix has been created.', 1383649061);
        }

        if (!$this->getIndex()->exists()) {
            throw new Exception('The target index for updateIndexAlias does not exist. This shall never happen.', 1383649125);
        }

        $aliasActions = [];
        try {
            $indexNames = $this->indexDriver->indexesByAlias($aliasName);

            if ($indexNames === []) {
                // if there is an actual index with the name we want to use as alias, remove it now
                $this->indexDriver->deleteIndex($aliasName);
            } else {
                foreach ($indexNames as $indexName) {
                    $aliasActions[] = [
                        'remove' => [
                            'index' => $indexName,
                            'alias' => $aliasName
                        ]
                    ];
                }
            }
        } catch (ApiException $exception) {
            // in case of 404, do not throw an error...
            if ($exception->getResponse()->getStatusCode() !== 404) {
                throw $exception;
            }
        }

        $aliasActions[] = [
            'add' => [
                'index' => $this->getIndexName(),
                'alias' => $aliasName
            ]
        ];

        $this->indexDriver->aliasActions($aliasActions);
    }
1034298
public function search(SearchCondition\SearchConditionInterface $filter, SelectOrder\SelectOrderInterface $order = null)
	{
		if ( ! ($filter instanceof SearchCondition\ArraySearchCondition)) {
			throw new Exception\WrongInstance($filter, 'SearchCondition\ArraySearchCondition');
		}
		$filterClosure = $filter->getSearchClosure();

		$orderClosure = null;
		if ( ! \is_null($order)) {
			if ( ! ($order instanceof SelectOrder\ArraySelectOrder)) {
				throw new Exception\WrongInstance($order, 'SelectOrder\ArraySelectOrder');
			}
			$orderClosure = $order->getOrderClosure();
		}

		$result = $this->searchByClosure($filterClosure, $orderClosure);
		
		return $result;
	}
1255278
public function indexQueuedItems()
    {
        $dispatcher = $this->getDispatcher();

        $log = $this->getLogger();
        $context = array('engine' => get_class($this->_searchEngine));
        $log->info('Indexing operation started', $context);

        try {

            // Ensure the schema object is populated. This routine will also
            // throw the SearchEvents::SCHEMA_ALTER event as well as detect
            // incompatible schemata.
            $this->getSchema();

            // Adds the search engine instance  as a subscriber only for the
            // duration of this indexing process.
            $dispatcher->addSubscriber($this->_searchEngine);

            $event = new SearchEngineEvent($this);
            $this->dispatchEvent(SearchEvents::SEARCH_ENGINE_PRE_INDEX, $event);

            // Consume messages from the queue that correspond with items that
            // are scheduled for indexing.
            $consumer = new QueueConsumer($this);
            foreach ($consumer as $message) {
                $context['item'] = $message->getBody();
                $log->debug('Consumed item scheduled for indexing from queue', $context);
                $this->indexQueuedItem($message);
            }

            unset($context['item']); // The item is no longer in context.
            $this->dispatchEvent(SearchEvents::SEARCH_ENGINE_POST_INDEX, $event);

            // The search engine should only listen to events throws during it's
            // own indexing operation.
            $dispatcher->removeSubscriber($this->_searchEngine);

        } catch (Exception $e) {
            // Make sure this service is removed as a subscriber. See above.
            $dispatcher->removeSubscriber($this->_searchEngine);
            throw $e;
        }

        $context['indexed'] = count($consumer);
        $log->info('Indexing operation completed', $context);
    }
392497
private function checkProperties()
    {
        if (!isset($this->listId)) {
            throw new \Exception('[listId] is not set', 1);
        }

        if (!isset($this->installationUrl)) {
            throw new \Exception('[installationUrl] is not set', 1);
        }

        if (!isset($this->apiKey)) {
            throw new \Exception('[apiKey] is not set', 1);
        }
    }
209740
public function filter($request)
	{
		foreach($this->_filters as $filter)
		{
			if(!$request = $filter->filter($request))
			{
				throw new Exception("Filter returned a null request");
			}
		}

		return $request;
	}
277741
protected function undefinedIndexAcces( $index ) {
		if ( $this->errorStrategy == \Pixel418\Iniliq::ERROR_AS_EXCEPTION ) {
			throw new \Exception( 'Undefined index: ' . $index );
		} else if ( $this->errorStrategy == \Pixel418\Iniliq::ERROR_AS_PHPERROR ) {
			trigger_error( 'Undefined index: ' . $index );
		}
	}
300460
public function atomAt($index)
    {
        $atom = $this->atomAtDefault($index);
        if (null === $atom) {
            throw new Exception\UndefinedAtomException($index);
        }

        return $atom;
    }
1268746
public function collectionLoader()
    {
        if (!isset($this->collectionLoader)) {
            throw new Exception(sprintf(
                'Collection Loader is not defined for "%s"',
                get_class($this)
            ));
        }

        return $this->collectionLoader;
    }
692390
function ExecuteSql()
    {
        $versionCompare = version_compare($this->installedVersion, $this->manifest->Version());
       
        if ($versionCompare > 0)
        {
            $bundle = $this->manifest->BundleName();
            throw new \Exception("Error instaling bundle $bundle: Previously installed version is greater than curren code version. Please re-install the bundle.");
        }
        else if ($versionCompare === 0)
        {
            return;
        }
        $engineFolder = $this->FindEngineFolder();
        if (!$engineFolder)
        {
            return;
        }
        $this->ExecuteScripts($engineFolder);       
    }
119021
public function runIndexing()
    {
        $iterator = $this->getResourceIterator();
        $indexIterator = new IndexIterator($iterator);
        $indexIterator->setServiceLocator($this->getServiceLocator());
        $searchService = $this->getServiceLocator()->get(Search::SERVICE_ID);
        $result = $searchService->index($indexIterator);
        $this->logDebug($result . ' resources have been indexed by ' . static::class);
        return $result;
    }
216706
public function execute()
    {
        $request = $this->initGraphqlRequest();
        $response = $request->postRaw(
            $this->buildPayload()
        );
        if ($response->getCode() !== 200) {
            throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response);
        }

        return ResultSetBuilder::fromHttpResponse($response);
    }
516609
public function useAlias($alias)
    {
        $aliasGetter = 'get'.ucfirst($alias).'Alias';

        if (! method_exists($this->indexConfigurator, $aliasGetter)) {
            throw new Exception(sprintf(
                'The index configurator %s doesn\'t have getter for the %s alias.',
                get_class($this->indexConfigurator),
                $alias
            ));
        }

        $this->payload['index'] = call_user_func([$this->indexConfigurator, $aliasGetter]);

        return $this;
    }
1345187
protected function _resolveFields($fields)
    {
        if (is_string($fields)) {
            $fields = [$fields];
        }

        if (!is_array($fields)) {
            throw new Exception('Invalid "fields" configuration.');
        }

        $types = array_keys(Type::map());

        foreach ($fields as $field => $type) {
            if (is_numeric($field) && is_string($type)) {
                unset($fields[$field]);
                $field = $type;
                $type = self::DEFAULT_TYPE;
                $fields[$field] = $type;
            }

            if (!in_array($type, $types)) {
                throw new Exception(sprintf('The field "%s" mapped type "%s" was not found.', $field, $type));
            }
        }

        return $fields;
    }
65829
public static function find($collection, $query = null, $fields = array())
  {
    static::checkConnexion();
    $collection = self::$db->$collection;
    if (is_string($query)) {
      $query = json_decode($query, true);
      if (!$query) {
        throw new \Exception('Requête JSON formulée incorrectement');
      }
    }
    if ($query) {
      return $collection->find($query, $fields);
    } else {
      return $collection->find(array(), $fields);
    }
  }
1292186
public function indexAction() {
        if (!$this->container->has("haven_core.category.read_handler"))
            throw new \Exception("haven_core.category.read_handler doesn't exist or isn't setted in service.yml");

        $entities = $this->container->get("haven_core.category.read_handler")->getAll();

        return array("entities" => $entities);
    }