Я хочу внедрить автозаполнение совпадений в Elasticsearch, я пытаюсь создать индекс с помощью php клиента. Но я получаю эту ошибку.
BadRequest400Exception: {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"analyzer on field [name] must be set when search_analyzer is set"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [hotel]: analyzer on field [name] must be set when search_analyzer is set","caused_by":{"type":"mapper_parsing_exception","reason":"analyzer on field [name] must be set when search_analyzer is set"}},"status":400}
use Elasticsearch\ClientBuilder;
require '../vendor/autoload.php';
$client = ClientBuilder::create()->build();
$params = [
'index' => 'hotel_index',
'body' => [
'settings' => [
'analysis' => [
'filter' => [
"ngram_filter" => [
"type" => "ngram",
"min_gram" => 2,
"max_gram" => 20
]
],
'analyzer' => [
"ngram_analyzer" => [
"type" => "custom",
"tokenizer" => "whitespace",
"filter" => [
"lowercase",
"asciifolding",
"ngram_filter"]
]
]
]
],
'mappings' => [
"hotel" => [
'properties' => [
"name" => [
"type" => "string",
"include_in_all" => true,
"index_analyzer" => "ngram_analyzer",
"search_analyzer" => "standard"],
"city" => [
"type" => "string",
"include_in_all" => true,
],
"country" => [
"type" => "string",
"include_in_all" => true,
]
],
// "boost" => 3,
]
]
]
];
$response = $client->indices()->create($params);
print_r($response);
Моя упругая поисковая версия
"version" : {
"number" : "2.4.1",
"build_snapshot" : false,
"lucene_version" : "5.5.2"},
Задача ещё не решена.
Других решений пока нет …