You are here

public function SolrDocument::loadMultiple in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/search_api/datasource/SolrDocument.php \Drupal\search_api_solr\Plugin\search_api\datasource\SolrDocument::loadMultiple()
  2. 8.2 src/Plugin/search_api/datasource/SolrDocument.php \Drupal\search_api_solr\Plugin\search_api\datasource\SolrDocument::loadMultiple()

File

src/Plugin/search_api/datasource/SolrDocument.php, line 173

Class

SolrDocument
Represents a datasource which exposes external Solr Documents.

Namespace

Drupal\search_api_solr\Plugin\search_api\datasource

Code

public function loadMultiple(array $ids) {
  $documents = [];
  try {

    // Query the index for the Solr documents.
    $results = $this->index
      ->query()
      ->addCondition('search_api_id', $ids, 'IN')
      ->execute()
      ->getResultItems();
    foreach ($results as $id => $result) {
      $documents[$id] = $this->solrDocumentFactory
        ->create($result);
    }
  } catch (SearchApiException $e) {

    // Couldn't load items from server, return an empty array.
  }
  return $documents;
}