Created
May 13, 2014 22:10
-
-
Save jhedstrom/2f2bfed1724ba021bc5d to your computer and use it in GitHub Desktop.
Search API Solr - index one node type as another
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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