I wanted to add a new mapping for a custom CCK field and therefore implemented hook_apachesolr_cck_fields_alter:

/**
 * Implementation of hook_apachesolr_cck_fields_alter().
 */
function simple_duration_apachesolr_cck_fields_alter(&$mappings) {
  $mappings['simple_duration'] = array(
    'simple_duration' => array(
      'indexing_callback' => 'simple_duration_indexing_callback',
      'display_callback' => 'simple_duration_display_callback',
      'index_type' => 'string',
      'facets' => TRUE,
    ),
  );
}

By using this code the function apachesolr_search_apachesolr_facets in apachesolr_search.module throws an error in line 691. The key 'field_type' of the variable $field is not set. By changig it to 'type' everything works fine.

Is there a bug or am I using the hook wrong?

CommentFileSizeAuthor
#4 apachesolr-1135526-04.patch911 bytesjhedstrom

Comments

jpmckinney’s picture

Category: bug » support
Status: Active » Fixed

field_type is taken from the CCK description of the field. Make sure you are implementing CCK hooks correctly.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Andrey Zakharov’s picture

Version: 6.x-2.0-beta3 » 6.x-2.x-dev
Status: Closed (fixed) » Active

Same issue here
a lot of
WD php: Notice: Undefined index: field_type in apachesolr_search_apachesolr_facets() (line 755 of [error]
/sites/all/modules/drupal-contrib/apachesolr/apachesolr_search.module).

fields are type=>nodereference

in fact, 'field_type' added in content_preprocess_content_field which has been called before theming field?
content.module:2463

$additions = array(
    'field_type' => $field['type'],

so, 'type' is primary origin.

jhedstrom’s picture

Status: Active » Needs review
StatusFileSize
new911 bytes

Andrey is correct, field_type isn't added until that preprocessor is run. Internally, CCK tends to use type instead. Attached is a simple patch to use type instead of field_type.

bwood’s picture

Above patch fixed the problem for me. Thanks.

nick_vh’s picture

Version: 6.x-2.x-dev » 6.x-1.x-dev

The 6.x-2.x version has been deprecated. Moving this to 6.x-1.x-dev

Status: Needs review » Needs work

The last submitted patch, apachesolr-1135526-04.patch, failed testing.

nick_vh’s picture

Status: Needs work » Closed (won't fix)

Since this does not apply to 6.x-1.x I am closing it