Answer the question
In order to leave comments, you need to log in
Can't create index in ElaticSearch: Types cannot be provided in put mapping requests, what's the problem?
error:
Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true.
$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);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question