Apache Solr Search, add taxonomy field in search results I'm really bumping my head on this.

I simply need to add tids from a term reference field on nodes returned by a solr search result.

It's a unique term reference.

I looked for the field in solr console and it's 'im_field_arbo'.

I followed this and that and came to this :

1.

    function MYMODULE_apachesolr_index_document_build(ApacheSolrDocument $document, $entity, $entity_type, $env_id) {
      if(isset($entity-&gt;field_arbo)) {
        $document-&gt;addField('im_field_arbo', $entity-&gt;field_arbo['und'][0]['tid']);
      }
    }


This doesn't throw back any errors.

2.

Then, to retrieve it, I tried either hook_apachesolr_query_alter, hook_apachesolr_query_prepare with :

    $query-&gt;addParam('im', 'im_field_arbo');


and hook_apachesolr_modify_query with :

    $params['im'] .= ',im_field_arbo';




Still, no trace of my field in my search results.

Any help ? Thx very much.



Update

I think my field is well indexed : _apachesolr_index_document_build_node works like a charm.

Now the question is : "How do I get them back in search results ?"
To show the field you have added to your Solr index you first need to add it to the search result. Add this to template.php

function template_preprocess_search_result(&amp;$variables) {
  $variables['im_field_arbo'] = $variables['result']['fields']['im_field_arbo'];
}


Then in your search-result.tpl.php you can access the field like this:

&lt;?php if ($im_field_arbo): ?&gt;
  &lt;?php print $im_field_arbo; ?&gt;
&lt;?php endif; ?&gt;