You are here

function hook_search_api_solr_documents_alter in Search API Solr 4.x

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. 7 search_api_solr.api.php \hook_search_api_solr_documents_alter()

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

Parameters

\Solarium\QueryType\Update\Query\Document[] $documents: An array of \Solarium\QueryType\Update\Query\Document\Document objects ready to be indexed, generated from $items array.

\Drupal\search_api\IndexInterface $index: The search index for which items are being indexed.

\Drupal\search_api\Item\ItemInterface[] $items: An array of items to be indexed, keyed by their item IDs.

1 function implements hook_search_api_solr_documents_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

search_api_solr_test_search_api_solr_documents_alter in tests/modules/search_api_solr_test/search_api_solr_test.module
Implements hook_search_api_solr_documents_alter().
1 invocation of hook_search_api_solr_documents_alter()
SearchApiSolrBackend::getDocuments in src/Plugin/search_api/backend/SearchApiSolrBackend.php

File

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

Code

function hook_search_api_solr_documents_alter(array &$documents, \Drupal\search_api\IndexInterface $index, array $items) {

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