Adding index to apache solr by Drupal hook

1. Add index by setMultiValue

function scp_solr_search_apachesolr_update_index(&$document, $node){
$document->setMultiValue(‘sm_field_xxxx’,
$node->field_xxxx[‘und’][0][‘value’]);

2. Add modify query

function scp_solr_search_apachesolr_modify_query(&$query, $caller){
$query->params[‘fl’] .= ‘,sm_field_xxxx’;

3. update solr and done ~!

* scp_solr_search is my module name Enjoy

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s