class MappingFactory in Elasticsearch Connector 8.2
Same name and namespace in other branches
- 8.7 src/ElasticSearch/Parameters/Factory/MappingFactory.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\MappingFactory
- 8.5 src/ElasticSearch/Parameters/Factory/MappingFactory.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\MappingFactory
- 8.6 src/ElasticSearch/Parameters/Factory/MappingFactory.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\MappingFactory
Class MappingFactory.
Hierarchy
- class \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\MappingFactory
Expanded class hierarchy of MappingFactory
File
- src/
ElasticSearch/ Parameters/ Factory/ MappingFactory.php, line 11
Namespace
Drupal\elasticsearch_connector\ElasticSearch\Parameters\FactoryView source
class MappingFactory {
/**
* Helper function. Get the elasticsearch mapping for a field.
*
* @param FieldInterface $field
*
* @return array|null
*/
public static function mappingFromField(FieldInterface $field) {
try {
$type = $field
->getType();
switch ($type) {
case 'text':
return [
'type' => 'string',
'boost' => $field
->getBoost(),
'analyzer' => 'snowball',
];
case 'uri':
case 'string':
case 'token':
return [
'type' => 'string',
'index' => 'not_analyzed',
];
case 'integer':
case 'duration':
return [
'type' => 'integer',
];
case 'boolean':
return [
'type' => 'boolean',
];
case 'decimal':
return [
'type' => 'float',
];
case 'date':
return [
'type' => 'date',
'format' => 'epoch_second',
];
case 'attachment':
return [
'type' => 'attachment',
];
}
} catch (ElasticsearchException $e) {
watchdog_exception('Elasticsearch Backend', $e);
}
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MappingFactory:: |
public static | function | Helper function. Get the elasticsearch mapping for a field. |