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->field_arbo)) {
$document->addField('im_field_arbo', $entity->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->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 ?"
addParam()
method inhook_apachesolr_query_alter()
). I have a nearly identical setup, just using a different field name, and it works greathook_apachesolr_index_document_build_node()
, with_node
on the end. Might be worth changing that, clearing the cache, and giving it a try