Adding fields to Drupal 7 Apache SOLR

The question: How to make SOLR return more fields with the search results (using the apachesolr module), knowing that all the standard Drupal fields are added to the SOLR index?

I found plenty of blog posts about how to do this in Drupal 6, but it’s changed a bit with the latest versions. Here it is:

function mymodule_apachesolr_query_alter(&$query) {
  $fl = $query->getParam('fl');
  $fl[] = 'teaser';
  $query->replaceParam('fl', $fl);
}
This entry was posted in IT. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *