search_api_elasticsearch
search_api_elasticsearch copied to clipboard
Alter documents before they are sent for indexing?
Original issue: https://www.drupal.org/node/2531674
Is there any hook to Document Alter in Elasticsearch?
something similar to Search Api Solr Document Alter?
<?php
/**
* Alter Solr documents before they are sent to Solr for indexing.
*
* @param array $documents
* An array of SearchApiSolrDocument objects ready to be indexed, generated
* from $items array.
* @param SearchApiIndex $index
* The search index for which items are being indexed.
* @param array $items
* An array of items being indexed.
*/
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');
}
}
?>