Drupal 6 如何在solr:drupal6中索引文本区域类型的cck字段

Drupal 6 如何在solr:drupal6中索引文本区域类型的cck字段,drupal-6,solr,Drupal 6,Solr,我已经创建了一个类型为textarea的cck字段,名称为field\u desc,如何在solr中索引该字段 我找到了这篇文章,我试过了,但它没有索引该文件,有人能帮忙吗 <?php // $Id$ /** * Implementation of hook_apachesolr_cck_fields_alter */ function example_apachesolr_cck_fields_alter(&$mappings) { // either for all

我已经创建了一个类型为textarea的cck字段,名称为field\u desc,如何在solr中索引该字段

我找到了这篇文章,我试过了,但它没有索引该文件,有人能帮忙吗

    <?php
// $Id$
/**
* Implementation of hook_apachesolr_cck_fields_alter
*/
function example_apachesolr_cck_fields_alter(&$mappings) {
  // either for all CCK of a given field_type and widget option
  // 'filefield' is here the CCK field_type. Correlates to $field['field_type']
  $mappings['text'] = array(
    'text_textarea' => array('callback' => 'example_callback', 'index_type' => 'string'),

  );

}



/**
* A function that gets called during indexing.
* @node The current node being indexed
* @fieldname The current field being indexed
*
* @return an array of arrays. Each inner array is a value, and must be
* keyed 'value' => $value
*/
function example_callback($node, $fieldname) {
  $fields = array();
  foreach ($node->$fieldname as $field) {
    // In this case we are indexing the filemime type. While this technically
    // makes it possible that we could search for nodes based on the mime type
    // of their file fields, the real purpose is to have facet blocks during
    // searching.
    $fields[] = array('value' => $field['field_desc']);
  }
  return $fields;
}

?>

我目前正在以一种漂亮、通用的方式添加它。如果您现在真的需要这项功能,请访问Drupal.org。我的代码目前位于,但希望我能将其包含在上游并发布


希望有帮助

每字段映射更易于控制

改变功能:

$mappings['per-field']['field_specialities'] = array(
  'index_type' => 'string',
  'callback' => 'ge_search_apachesolr_field_specialities_callback'
);
回拨:

function ge_search_apachesolr_field_specialities_callback($node, $fieldname)
{
  $fields = array();
  foreach($node->$fieldname as $field) {
    $fields[] = array('value' => $field['value']);
  }
  return $fields;
}

结果怎么样?线程中提到的要使用的补丁是什么?您的代码将保留为一个单独的分支还是添加回主要的apachesolr开发中?