Hello,

My Environment.

Pressflow drupal 6.19
Apache Solr 6.x-1.2
CCK 6.x-2.8

I am using apache solr for one of my projects. My requirement is to add one of the CCK fields of my node as a search result filter(Facet). In the module page there is a mention that i can use CCK as a filter, I read thru the apachesolr module documentation page and coudn't find out how.

Did some search and also found this blog post http://acquia.com/blog/understanding-apachesolr-cck-api. Which explains how to create a custom facet.

My Questions is.

1. Do i need to write custom code to use CCK fliters for all CCK field types or is it provided by default.
2. If its provided by default, Then how to configure it.

Thanks in advance

Comments

venkiparam’s picture

Thanks mysty

I found a solution for this as well. You can use the apache_solr hooks to add dynamic fields in the solr index.

/*
* This allows us to add dynamic feilds to the solr index. For any cck feilds where filtering
* is required, this is the place to add the required feilds.
*/
function hook_apachesolr_cck_fields_alter(&$mappings){
$mappings['per-field'][''] = array('callback' => '', 'index_type' => 'string');
}

This will add the cck field to the solr index and you will also be able to filter based on this field.

puhig’s picture

Hi,

What file would have to modify?

Thanks

rhymeswithcamera’s picture

If you go to the "Apache Solr" settings under "Site Configuration," you should see an "Enabled Filters" tab. By default, it should include a list of your site's CCK fields and taxonomy/vocabularies. You select which ones you want facets/filters for, save, and it will create these facets as blocks. You then go to Blocks (or Context) to enable. There is also a module called Apache Solr Facet Builder that lets you create custom facets.