You are here

function geofield_apachesolr_index in Geofield 7

Name callback for field name

1 string reference to 'geofield_apachesolr_index'
geofield_apachesolr_field_mappings in ./geofield.module
Implements hook_apachesolr_field_mappings().

File

./geofield.module, line 265

Code

function geofield_apachesolr_index($node, $field_name, $index_key, $field_info) {
  $return = array();
  if (isset($node->{$field_name})) {

    // Load the instance settings for the field
    $instance = field_info_instance('node', $field_name, $node->type);
    if (!empty($instance['settings']['solrspatial'])) {
      if ($values = field_get_items('node', $node, $field_name)) {
        $values = reset($values);
        $return = array(
          array(
            'key' => $instance['settings']['solrspatial']['lat_field'],
            'value' => $values['lat'],
          ),
          array(
            'key' => $instance['settings']['solrspatial']['lng_field'],
            'value' => $values['lon'],
          ),
          array(
            'key' => $instance['settings']['solrspatial']['latlng_field'],
            'value' => $values['lat'] . ',' . $values['lon'],
          ),
          array(
            'key' => 'ss_geo_wkt',
            'value' => $values['wkt'],
          ),
        );
      }
    }
  }
  return $return;
}