You are here

public static function IndexFactory::mapping in Elasticsearch Connector 8.2

Same name and namespace in other branches
  1. 8.7 src/ElasticSearch/Parameters/Factory/IndexFactory.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\IndexFactory::mapping()
  2. 8.5 src/ElasticSearch/Parameters/Factory/IndexFactory.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\IndexFactory::mapping()
  3. 8.6 src/ElasticSearch/Parameters/Factory/IndexFactory.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\IndexFactory::mapping()

Build parameters required to create an index mapping TODO: We need also: $params['index'] - (Required) ['type'] - The name of the document type ['timeout'] - (time) Explicit operation timeout

Parameters

\Drupal\search_api\IndexInterface $index:

Return value

mixed

1 call to IndexFactory::mapping()
SearchApiElasticsearchBackend::fieldsUpdated in src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php

File

src/ElasticSearch/Parameters/Factory/IndexFactory.php, line 136

Class

IndexFactory
Class IndexFactory.

Namespace

Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory

Code

public static function mapping(IndexInterface $index) {
  $params = IndexFactory::index($index, TRUE);
  $properties = [
    'id' => [
      'type' => 'string',
      'index' => 'not_analyzed',
      'include_in_all' => FALSE,
    ],
  ];

  // Map index fields.
  foreach ($index
    ->getFields() as $field_id => $field_data) {
    $properties[$field_id] = MappingFactory::mappingFromField($field_data);
  }
  $params['body'][$params['type']]['properties'] = $properties;
  return $params;
}