You are here

protected function SearchApiElasticsearchIndex::getFieldMapping in Search API Elasticsearch 7.2

Map Search API field types to Elasticsearch field types.

Parameters

$field:

Return value

array|null

1 call to SearchApiElasticsearchIndex::getFieldMapping()
SearchApiElasticsearchIndex::setMapping in includes/SearchApiElasticsearchIndex.inc
Set Elasticsearch mapping.

File

includes/SearchApiElasticsearchIndex.inc, line 213

Class

SearchApiElasticsearchIndex

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;
  }
}