Drupal apachesolr 的原設定是不會 將 textarea 的文字作為 index 的一部份傳到 solr 的
只會將 body 和 teaser 傳到
原因是 textarea 的 fulltext search 需要 index 的機會很少
但也做成另一個問題, 就是返回 search result 的時候
如果顯示結果需要
<?php
/**
* Drupal default do not index images and textarea, add them to index too for search result display
**/
function ge_search_apachesolr_cck_fields_alter(&$mappings)
{
$mappings['per-field']['field_main_image'] = array(
'index_type' => 'string',
'callback' => 'ge_search_apachesolr_field_main_image_callback'
);
$mappings['per-field']['field_specialities'] = array(
'index_type' => 'string',
'callback' => 'ge_search_apachesolr_field_specialities_callback'
);
}
function ge_search_apachesolr_field_main_image_callback($node, $fieldname)
{
$fields = array();
foreach($node->$fieldname as $field) {
$fields[] = array('value' => $field['filepath']);
}
return $fields;
}
function ge_search_apachesolr_field_specialities_callback($node, $fieldname)
{
$fields = array();
foreach($node->$fieldname as $field) {
$fields[] = array('value' => $field['value']);
}
return $fields;
}
?>
ref: http://www.acquia.com/blog/understanding-apachesolr-cck-api