I manage an ubercart store that is indexed by Apache Solr. The search indexes the sell price and it's one of the facets. However, the price is nowhere in search-result.tpl.php. It's also not available in the search results preprocess hook in template.php. Is there somewhere else I can inject it into the search results without performing a separate database query for each search result.

1 Answer 1


You can index it using solr's dynamic fields (see your schema.xml in the solr conf directory) and a custom module hook, namely hook_apachesolr_update_index().

Then you can, at search time, add the field you have indexed into the fields being fetched. For this you have three hooks or 'hooks' to choose from: hook_apachesolr_prepare_query(), hook_apachesolr_modify_query() and CALLER_finalize_query().

For further information on the hooks, see the README.txt in the apachesolr module directory.

Then in your search-result.tpl.php you'll have available the custom indexed field as $result['fields']['your_field_name'].


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.