You are here

public function SearchApiSolrBackend::executeGraphStreamingExpression in Search API Solr 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::executeGraphStreamingExpression()
  2. 4.x src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::executeGraphStreamingExpression()

Executes a graph streaming expression.

Parameters

\Drupal\search_api\Query\QueryInterface $query:

Return value

\Solarium\QueryType\Graph\Result

Throws

\Drupal\search_api\SearchApiException

\Drupal\search_api_solr\SearchApiSolrException

Overrides SolrBackendInterface::executeGraphStreamingExpression

File

src/Plugin/search_api/backend/SearchApiSolrBackend.php, line 1358

Class

SearchApiSolrBackend
Apache Solr backend for search api.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

public function executeGraphStreamingExpression(QueryInterface $query) {
  $stream_expression = $query
    ->getOption('solr_streaming_expression', FALSE);
  if (!$stream_expression) {
    throw new SearchApiSolrException('Streaming expression missing.');
  }
  $connector = $this
    ->getSolrConnector();
  if (!$connector instanceof SolrCloudConnectorInterface) {
    throw new SearchApiSolrException('Streaming expression are only supported by a Solr Cloud connector.');
  }
  $this
    ->finalizeIndex($query
    ->getIndex());
  $graph = $connector
    ->getGraphQuery();
  $graph
    ->setExpression($stream_expression);
  $this
    ->applySearchWorkarounds($graph, $query);
  try {
    return $connector
      ->graph($graph);
  } catch (\Exception $e) {
    throw new SearchApiSolrException('An error occurred while trying execute a streaming expression on Solr: ' . $e
      ->getMessage(), $e
      ->getCode(), $e);
  }
}