I'm trying to add some custom fields(image field, text field) in Apache Solr's search result. I ended up found the code below; however, I don't know:
- Where to put this code (is it template.php?)
- How to get the information to display them.
`
function mymodule_apachesolr_update_index($document, $node, $namespace) {
// When indexing nodes, add field from my custom content type.
if ($node->type === 'my_contenttype') {
// Grab the image URI and the description.
$image_uri = $node->field_image['und'][0]['uri'];
$description = $node->field_description['und'][0]['safe_value'];
// Add the image and description to the document in the solr index.
$document->addField('ss_my_contenttype_image', $image_uri);
$document->addField('ts_my_contenttype_description', $description);
}
}
function mymodule_apachesolr_query_prepare($query) {
// Add the image.
$query->addParam('fl', 'ss_my_contenttype_image');
// Add the description text.
$query->addParam('fl', 'ts_my_contenttype_description');
}
I appreciate any advice. Thank you.