@great_77

Не могу создать индекс в ElaticSearch: Types cannot be provided in put mapping requests, в чем проблема?

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);
  • Вопрос задан
  • 808 просмотров
Решения вопроса 1
@great_77 Автор вопроса
Turn on: include_type_name
https://stackoverflow.com/questions/56803895/elast...
$mapping = new \Elastica\Type\Mapping();
        $mapping->setType($elasticaType); 
        $mapping->setProperties($params);

        $mapping->send(['include_type_name' => true]);
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы