function apachesolr_datestamp_default_indexing_callback in Apache Solr Search 7
Same name and namespace in other branches
- 8 apachesolr.index.inc \apachesolr_datestamp_default_indexing_callback()
- 6.3 apachesolr.index.inc \apachesolr_datestamp_default_indexing_callback()
This function is used during indexing to normalize the DATESTAMP fields into the appropriate format for Apache Solr.
Parameters
object $entity:
string $field_name:
string $index_key:
array $field_info:
Return value
array $fields
1 string reference to 'apachesolr_datestamp_default_indexing_callback'
- date_apachesolr_field_mappings in ./
apachesolr.module - Implements hook_apachesolr_field_mappings() on behalf of date module.
File
- ./
apachesolr.index.inc, line 1287 - Functions related to Apache Solr indexing operations.
Code
function apachesolr_datestamp_default_indexing_callback($entity, $field_name, $index_key, array $field_info) {
$fields = array();
if (!empty($entity->{$field_name})) {
// $fields may end up having two values; one for the start date
// and one for the end date.
$field = $entity->{$field_name};
$values = current($field);
foreach ($values as $value) {
if (isset($value['value']) && $value['value'] != 0) {
$index_value = apachesolr_date_iso($value['value']);
$fields[] = array(
'key' => $index_key,
'value' => $index_value,
);
}
if (isset($value['value2']) && $value['value'] != 0) {
$index_value = apachesolr_date_iso($value['value2']);
$fields[] = array(
// The value2 element is the end date. Therefore it gets indexed
// into its own Solr field.
'key' => $index_key . '_end',
'value' => $index_value,
);
}
}
}
return $fields;
}