VeggieMeat / search_api_elasticsearch

Clone of project at drupal.org/project/search_api_elasticsearch for better CI options than what D.O offers
16 stars 8 forks source link

Alter documents before they are sent for indexing? #81

Open VeggieMeat opened 9 years ago

VeggieMeat commented 9 years ago

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');
  }
}
?>