Я хочу создать собственную функцию оценки для лучших результатов.
Я хочу запросить, где tenant_id равен 15, а customer_org_type - OA. Теперь, если найден print_address с нечеткостью 3, укажите вес 5, а если найдено имя_регистрации с нечеткостью 3, укажите вес 10., но не получите [запрос], зарегистрированный для ошибки [function_score].
GET addresses-index/_search
{
"from": 0,
"size": 10,
"query": {
"function_score": {
"query": {"bool": {}},
"boost": "5",
"functions": [
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{"match": {"tenant_id": "15"}},
{"match": {"customer_org_type": "LP"}}
]
}
},
"must": [
{
"match": [
{
"print_address": {
"query": "FULL ADDRESS HERE",
"fuzziness": 3,
"random_score": {},
"weight": 5
}
},
{
"registered_name": {
"query": "NAME OF THE COMPANY",
"fuzziness": 3,
"random_score": {},
"weight": 10
}
}
]
}
]
}
}
}
],
"max_boost": 42,
"score_mode": "max",
"boost_mode": "multiply",
"min_score": 42
}
}
}
Ниже приведен запрос, приведенный в документации, которую я использовал для справки.
GET /_search
{
"query": {
"function_score": {
"query": { "match_all": {} },
"boost": "5",
"functions": [
{
"filter": { "match": { "test": "bar" } },
"random_score": {},
"weight": 23
},
{
"filter": { "match": { "test": "cat" } },
"weight": 42
}
],
"max_boost": 42,
"score_mode": "max",
"boost_mode": "multiply",
"min_score" : 42
}
}
}