$params = [
'index' => 'products',
'body' => [
'settings' => [
'number_of_shards' => 3,
'number_of_replicas' => 1,
"analysis" => [
"filter" => [
"russian_stop" => [
"type" => "stop",
"stopwords" => "_russian_"
],
"russian_keywords" => [
"type" => "keyword_marker",
"keywords" => []
],
"russian_stemmer" => [
"type" => "stemmer",
"language" => "russian"
],
"edge_ngram_filter" => [
"type" => "edge_ngram",
"min_gram" => 1,
"max_gram" => 20
]
],
"analyzer" => [
"rebuilt_russian" => [
"tokenizer" => "standard",
"filter" => [
"lowercase",
"russian_stop",
"russian_keywords",
"russian_stemmer"
]
],
"edge_ngram_analyzer" => [
"tokenizer" => "standard",
"filter" => [
"lowercase",
"edge_ngram_filter"
]
]
]
],
],
'mappings' => [
'properties' => [
'name' => [
'type' => 'text',
'analyzer' => 'rebuilt_russian',
'fields' => [
"edge_ngram" => [
"type" => "text",
"analyzer" => "edge_ngram_analyzer"
]
]
],
'description' => [
'type' => 'text',
'analyzer' => 'rebuilt_russian',
'fields' => [
"edge_ngram" => [
"type" => "text",
"analyzer" => "edge_ngram_analyzer"
]
]
],
'age' => [
'type' => 'integer',
'null_value' => null,
],
'price' => [
'type' => 'integer'
],
'gender' => [
'type' => 'keyword',
'null_value' => null,
]
]
]
]
];
PUT /pets_index
{
"settings": {
"analysis": {
"filter": {
"pet_synonyms": {
"type": "synonym",
"synonyms": [
"собака, щенок, кобель => dog",
"кошка, кот, котёнок => cat",
"попугай, попугайчик => parrot"
]
}
},
"analyzer": {
"pet_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "pet_synonyms"]
}
}
}
},
"mappings": {
"properties": {
"pet_type": {
"type": "text",
"analyzer": "pet_analyzer"
}
}
}
}