Маппинг:
$params = [
'index' => $config['es']['default_index'],
'type' => $config['es']['default_type'],
'body' => [
'_source' => [
'enabled' => true
],
'properties' => [
'external_id' => [
'type' => 'text',
'index' => false,
],
'item_name' => [
'type' => 'text',
'analyzer' => 'standard',
'search_analyzer' => 'standard',
'fielddata' => true,
'term_vector' => 'with_positions_offsets',
],
]
]
];
$client->indices()->putMapping($params);
Запрос:
GET sark/item/_search
{
"size": 120,
"query": {
"query_string": {
"fields": ["item_name"],
"query": "молоко ультрапастеризованное продукция"
}
},
"highlight": {
"fields": {
"item_name": {}
}
}
}
Ответ:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 184,
"max_score": 23.819998,
"hits": [
{
"_index": "sark",
"_type": "item",
"_id": "9d090b20-34c2-429c-855d-07a42c16a131",
"_score": 23.819998,
"_source": {
"external_id": "9d090b20-34c2-429c-855d-07a42c16a131",
"item_name": "Молоко питьевое коровье ультрапастеризованное"
}
},
{
"_index": "sark",
"_type": "item",
"_id": "69046b91-5c7c-4536-bbe5-ea4ae357f716",
"_score": 23.169369,
"_source": {
"external_id": "69046b91-5c7c-4536-bbe5-ea4ae357f716",
"item_name": "Молоко питьевое ультрапастеризованное (ультравысокотемпературно-обработанное)"
}
},
{
"_index": "sark",
"_type": "item",
"_id": "325135cd-dda5-4317-897b-5f4aedb43944",
"_score": 22.506695,
"_source": {
"external_id": "325135cd-dda5-4317-897b-5f4aedb43944",
"item_name": "Молоко и молочная продукция"
}
},
{
"_index": "sark",
"_type": "item",
"_id": "4d07acd6-36d8-4949-907d-7fa147fccfc6",
"_score": 22.506695,
"_source": {
"external_id": "4d07acd6-36d8-4949-907d-7fa147fccfc6",
"item_name": "Молоко и молочная продукция"
}
},
{
"_index": "sark",
"_type": "item",
"_id": "8436eda6-9faf-41a4-b84e-a964bfd01671",
"_score": 22.506695,
"_source": {
"external_id": "8436eda6-9faf-41a4-b84e-a964bfd01671",
"item_name": "Молоко и молочная продукция"
}
},
{
"_index": "sark",
"_type": "item",
"_id": "51828aae-754b-4190-b404-e359fd7a6fcf",
"_score": 22.059921,
"_source": {
"external_id": "51828aae-754b-4190-b404-e359fd7a6fcf",
"item_name": "Молоко и молочная продукция"
}
},
{
"_index": "sark",
"_type": "item",
"_id": "83fb278c-f127-4f2f-a09c-ee4d44f9dff5",
"_score": 22.059921,
"_source": {
"external_id": "83fb278c-f127-4f2f-a09c-ee4d44f9dff5",
"item_name": "Молоко и молочная продукция"
}
},
{
"_index": "sark",
"_type": "item",
"_id": "97aea5b4-a223-4b14-989f-8a530d76e709",
"_score": 22.059921,
"_source": {
"external_id": "97aea5b4-a223-4b14-989f-8a530d76e709",
"item_name": "Молоко и молочная продукция"
}
},
{
"_index": "sark",
"_type": "item",
"_id": "b74ab5af-f694-43f3-9f53-f06c9887cd0d",
"_score": 22.059921,
"_source": {
"external_id": "b74ab5af-f694-43f3-9f53-f06c9887cd0d",
"item_name": "Молоко и молочная продукция"
}
},
{
"_index": "sark",
"_type": "item",
"_id": "c86cfbc5-bffb-4fd6-a4b4-77911f8ec85d",
"_score": 22.059921,
"_source": {
"external_id": "c86cfbc5-bffb-4fd6-a4b4-77911f8ec85d",
"item_name": "Молоко и молочная продукция"
}
}
]
}
}
У документов "Молоко и молочная продукция" разные веса - Почему?