Apache Solr Custom Fields

apache solr index mechanism
apache solr screenshot

Apache Solr module helps you to integrate the ApacheSolr to Drupal, but this module doesn't include all CCK Fields.

Here are 2 HOOKs to add your custom fields to Apachesolr,

1. HOOK_apachesolr_cck_fields_alter
arguments: &$mappings,
add your field_name to this array, and return.

$mapping[‘per-field’][$field_name] =array('callback' => '', 'index_type' => 'string');

2. HOOK_apachesolr_update_index
arugments: $document, $node, $namespace.
so you can add any field to the $document.

Use Apachesolr Custom Fields to get out of any custom code to do this, what you need to is go to administration page and add some settings to determine which field need to be indexed or not.

The mechanism is to store all cck fields settings into database, and add your custom fields settings into database also.
Further more, this module convert those 2 hooks into the same one, and the same interface.
When you go to the page, index.php?admin/settings/apachesolr/custom-fields, there is a list of cck fields, and a link you can add your custom field. Go each field settings page on the page, you will get a page which contains more description on the page.

Apache Solr Indexing Mechanism
ApacheSolr indexing mechanism

Install Apachesolr and config it correctly.

1. copy module to you drupal module folder.
2. enable it.

Some Videos:

Since Apache Solr module has ability to index custom fields in Drupal 7, so this module won't be developed in Drupal 7.

Any problem, please visit my blog Drupal与高性能网站架构 | Drupal大学

Credit by: 广州Drupal开发

Apache Solr Custom Fields项目的Drush安装命令:复制到剪贴板