function hook_apachesolr_field_mappings_alter in Apache Solr Search 8
Same name and namespace in other branches
- 6.3 apachesolr.api.php \hook_apachesolr_field_mappings_alter()
- 7 apachesolr.api.php \hook_apachesolr_field_mappings_alter()
Alter hook for apachesolr_field_mappings().
Add or alter index mappings for Field API types. The default mappings array handles just list fields and taxonomy term reference fields, in the same way as documented in hook_apachesolr_field_mappings.
Parameters
array $mappings: An associative array of mappings as defined by modules that implement hook_apachesolr_field_mappings().
string $entity_type: The entity type for which you want to alter the field mappings
1 invocation of hook_apachesolr_field_mappings_alter()
- apachesolr_entity_fields in ./
apachesolr.module - Returns array containing information about node fields that should be indexed
File
- ./
apachesolr.api.php, line 125 - Exposed Hooks in 7.x:
Code
function hook_apachesolr_field_mappings_alter(array &$mappings, $entity_type) {
// Enable indexing for text fields
$mappings['text'] = array(
'indexing_callback' => 'apachesolr_fields_default_indexing_callback',
'map callback' => '',
'index_type' => 'string',
'facets' => TRUE,
'facet missing allowed' => TRUE,
'dependency plugins' => array(
'bundle',
'role',
),
'hierarchy callback' => FALSE,
'name callback' => '',
'facet mincount allowed' => FALSE,
'multiple' => FALSE,
);
// Add our per field mapping here so we can sort on the
// price by making it single. Solr cannot sort on multivalued fields
// field_price is our identifier of a custom field, and it was decided to
// index in the same way as a number_float field.
$mappings['per-field']['field_price'] = $mappings['number_float'];
$mappings['per-field']['field_price']['multiple'] = FALSE;
}