public function SearchApiSolrBackend::executeGraphStreamingExpression in Search API Solr 4.x
Same name and namespace in other branches
- 8.3 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::executeGraphStreamingExpression()
 - 8.2 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::executeGraphStreamingExpression()
 
Throws
\Drupal\Component\Plugin\Exception\PluginException
Overrides SolrBackendInterface::executeGraphStreamingExpression
File
- src/
Plugin/ search_api/ backend/ SearchApiSolrBackend.php, line 2003  
Class
- SearchApiSolrBackend
 - Apache Solr backend for search api.
 
Namespace
Drupal\search_api_solr\Plugin\search_api\backendCode
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.');
  }
  $index = $query
    ->getIndex();
  $this
    ->finalizeIndex($index);
  $graph = $connector
    ->getGraphQuery();
  $graph
    ->setExpression($stream_expression);
  $this
    ->applySearchWorkarounds($graph, $query);
  try {
    return $connector
      ->graph($graph, $this
      ->getCollectionEndpoint($index));
  } catch (\Exception $e) {
    throw new SearchApiSolrException('An error occurred while trying execute a streaming expression on Solr: ' . $e
      ->getMessage(), $e
      ->getCode(), $e);
  }
}