You are here

public function SearchApiElasticsearchConnector::getFieldMapping in Elasticsearch Connector 7.5

Same name and namespace in other branches
  1. 7 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::getFieldMapping()
  2. 7.2 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::getFieldMapping()

Helper function. Get the elasticsearch mapping for a field.

1 call to SearchApiElasticsearchConnector::getFieldMapping()
SearchApiElasticsearchConnector::fieldsUpdated in modules/elasticsearch_connector_search_api/service.inc
Overrides fieldsUpdated().

File

modules/elasticsearch_connector_search_api/service.inc, line 1088
Provides a Elasticsearch-based service class for the Search API using Elasticsearch Connector module.

Class

SearchApiElasticsearchConnector
Search service class.

Code

public function getFieldMapping($field) {

  // Support of the custom data types. When such is implemented the type is
  // stored in the $field['real_type'] and the $field['type'] contains the
  // fallback type that will be used if the custom one is not supported.
  $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' => 'text',
        'boost' => $field['boost'],
        // Index also FIELD.raw in order to have also the field
        // not analyzed if needed.
        // TODO: This should be decided via settings.
        'fields' => array(
          'keyword' => array(
            'type' => 'keyword',
            'ignore_above' => 256,
          ),
        ),
      );
    case 'uri':
    case 'string':
    case 'token':
      return array(
        'type' => 'keyword',
      );
    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' => 'epoch_second',
      );
    case 'location':
      return array(
        'type' => 'geo_point',
        'lat_lon' => TRUE,
      );
    default:
      return NULL;
  }
}