You are here

protected function SearchApiElasticsearchAbstractService::getFieldMapping in Search API Elasticsearch 7

Helper function. Get the Elasticsearch mapping for a field.

1 call to SearchApiElasticsearchAbstractService::getFieldMapping()
SearchApiElasticsearchAbstractService::fieldsUpdated in includes/SearchApiElasticsearchAbstractService.inc
Overrides fieldsUpdated().

File

includes/SearchApiElasticsearchAbstractService.inc, line 450
Provides a Elasticsearch-based service class for the Search API.

Class

SearchApiElasticsearchAbstractService
Elasticsearch service abstract class.

Code

protected function getFieldMapping($field) {
  $field_type = isset($field['real_type']) ? $field['real_type'] : $field['type'];
  $type = search_api_extract_inner_type($field_type);
  switch ($type) {
    case 'text':
      return array(
        'type' => 'string',
        'boost' => $field['boost'],
      );
    case 'uri':
    case 'string':
    case 'token':
      return array(
        'type' => 'string',
        'index' => 'not_analyzed',
      );
    case 'integer':
    case 'duration':
      return array(
        'type' => 'integer',
      );
    case 'boolean':
      return array(
        'type' => 'boolean',
      );
    case 'decimal':
      return array(
        'type' => 'float',
      );
    case 'date':
      return array(
        'type' => 'date',
        'format' => 'date_time',
      );
    case 'location':
      return array(
        'type' => 'geo_point',
        'lat_lon' => TRUE,
      );
    default:
      return NULL;
  }
}