You are here

function apachesolr_text_cck_text_indexing_callback in Apache Solr Search 6.2

A replacement indexing callback for optionwidget text fields for when content_permissions are in use. Splits the indexing of these fields into a dynamic string field and a dynamic text field. This allows for both searching and faceting on the field.

1 string reference to 'apachesolr_text_cck_text_indexing_callback'
apachesolr_text_apachesolr_cck_fields_alter in contrib/apachesolr_text/apachesolr_text.module

File

contrib/apachesolr_text/apachesolr_text.module, line 28

Code

function apachesolr_text_cck_text_indexing_callback($node, $field_name, $cck_info) {
  $fields = array();
  if (isset($node->{$field_name})) {
    $index_key_string = apachesolr_index_key($cck_info);

    // Generate a key for text as well.
    $cck_info['index_type'] = 'text';
    $index_key_text = apachesolr_index_key($cck_info);
    foreach ($node->{$field_name} as $field) {
      if ($index_value = isset($field['safe']) && strlen($field['safe']) ? $field['safe'] : FALSE) {
        $fields[] = array(
          'key' => $index_key_string,
          'value' => $index_value,
        );

        // Index the field a second time as text so that we can search on it.
        $fields[] = array(
          'key' => $index_key_text,
          'value' => $index_value,
        );
      }
    }
  }
  return $fields;
}