Skip to content

Instantly share code, notes, and snippets.

@jhedstrom
Created May 13, 2014 22:10
Show Gist options
  • Save jhedstrom/2f2bfed1724ba021bc5d to your computer and use it in GitHub Desktop.
Save jhedstrom/2f2bfed1724ba021bc5d to your computer and use it in GitHub Desktop.
Search API Solr - index one node type as another
<?php
/**
* Implements hook_search_api_solr_documents_alter().
*
* Legacy pages should simply be indexed as normal pages.
*/
function MYMODULE_search_api_solr_documents_alter(array &$documents, SearchApiIndex $index, array $items) {
if ($index->item_type == 'node') {
foreach ($documents as $document) {
if ($type = $document->getField('ss_type')) {
if ($type['value'] == 'legacy_page') {
// Set index value for this field to 'page'.
$document->setField('ss_type', 'page');
}
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment