Error: Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true.
Technologies: PHP, Elastica
При добавлении маппинга к созданному индексу:
$elasticaType = $elasticaIndex->getType('single');
$params = [
'id' => [
'type' => 'integer',
],
'user' => [
'type' => 'object',
'properties' => [
'name' => [
'type' => 'keyword',
],
'fullName' => [
'type' => 'keyword',
]
]
],
'name' => [
'type' => 'keyword',
'boost' => 2
],
'description' => [
'type' => 'text'
],
'price' => [
'type' => 'integer'
],
'date' => [
'type' => 'date'
]
];
$mapping = new \Elastica\Type\Mapping();
$mapping->setType($elasticaType);
$mapping->setProperties($params);
$mapping->send();
Создание индекса:
$hosts = [
'host' => 'elasticsearch',
'port' => 9200
];
$client = new Client($hosts);
$elasticaIndex = $client->getIndex('track');
$params = [
'settings' => [
'number_of_shards' => 2,
'number_of_replicas' => 1,
'analysis' => [
'analyzer' => [
'default' => [
'type' => 'custom',
'tokenizer' => 'standard',
'filter' => ['lowercase', 'mySnowball']
],
'default_search' => [
'type' => 'custom',
'tokenizer' => 'standard',
'filter' => ['standard', 'lowercase', 'mySnowball']
]
],
'filter' => [
'mySnowball' => [
'type' => 'snowball',
'language' => 'English'
]
]
]
]
];
$elasticaIndex->create($params, true);