You are here

function hook_search_api_solr_documents_alter in Search API Solr 7

Same name and namespace in other branches
  1. 8.3 search_api_solr.api.php \hook_search_api_solr_documents_alter()
  2. 8 search_api_solr.api.php \hook_search_api_solr_documents_alter()
  3. 8.2 search_api_solr.api.php \hook_search_api_solr_documents_alter()
  4. 4.x search_api_solr.api.php \hook_search_api_solr_documents_alter()

Alter Solr documents before they are sent to Solr for indexing.

Parameters

array $documents: An array of SearchApiSolrDocument objects ready to be indexed, generated from $items array.

SearchApiIndex $index: The search index for which items are being indexed.

array $items: An array of items being indexed.

1 invocation of hook_search_api_solr_documents_alter()
SearchApiSolrService::indexItems in includes/service.inc
Indexes the specified items.

File

./search_api_solr.api.php, line 60
Hooks provided by the Search API Solr search module.

Code

function hook_search_api_solr_documents_alter(array &$documents, SearchApiIndex $index, array $items) {

  // Adds a "foo" field with value "bar" to all documents.
  foreach ($documents as $document) {
    $document
      ->setField('foo', 'bar');
  }
}