Я пытаюсь получить сумму баллов с помощью сценария входа в систему из групп, полученных в результате поиска с помощью function_scores. Я sh должен иметь что-то вроде:
markable-1 -> 80
markable-2 -> 20
Моя проблема в том, что я знаю, как суммировать баллы для сегментов, но я не знаю, как выполнить сценарий score_script вместо суммы.
На самом деле у меня есть:
{
"query": {
"function_score": {
"query": {
"term": {
"source": {
"value": 345
}
}
},
"boost_mode": "multiply",
"functions": [
{
"filter": {
"match": {
"annotable": "annotable-1"
}
},
"random_score": [],
"weight": 80
},
{
"filter": {
"match": {
"annotable": "annotable-2"
}
},
"random_score": [],
"weight": 20
}
],
"min_score": 0,
"score_mode": "max"
}
},
"aggs": {
"by_markable": {
"terms": {
"field": "markable"
},
"aggs": {
"scores": {
"sum": {
"script": {
"source": "_score"
}
}
}
}
}
}
}
это дает хорошие результаты:
{
"took": 8,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 41,
"relation": "eq"
},
"max_score": 80,
"hits": [
{
"_index": "ew_mark",
"_type": "ew_mark",
"_id": "530",
"_score": 80,
"_source": {
"id": 530,
"markable": "119",
"annotable": "annotable-2",
"source": 25,
}
},
{
"_index": "ew_mark",
"_type": "ew_mark",
"_id": "16020",
"_score": 20,
"_source": {
"id": 16020,
"markable": "119",
"annotable": "annotable-1",
"source": 25,
}
},
{
"_index": "ew_mark",
"_type": "ew_mark",
"_id": "16021",
"_score": 20,
"_source": {
"id": 16021,
"markable": "119",
"annotable": "annotable-1",
"source": 25,
}
},
{
"_index": "ew_mark",
"_type": "ew_mark",
"_id": "16022",
"_score": 20,
"_source": {
"id": 16022,
"markable": "119",
"annotable": "annotable-1",
"source": 25,
}
},
{
"_index": "ew_mark",
"_type": "ew_mark",
"_id": "16023",
"_score": 20,
"_source": {
"id": 16023,
"markable": "119",
"annotable": "annotable-1",
"source": 25,
}
},
{
"_index": "ew_mark",
"_type": "ew_mark",
"_id": "16024",
"_score": 20,
"_source": {
"id": 16024,
"markable": "119",
"annotable": "annotable-1",
"source": 25,
}
},
{
"_index": "ew_mark",
"_type": "ew_mark",
"_id": "16025",
"_score": 20,
"_source": {
"id": 16025,
"markable": "119",
"annotable": "annotable-1",
"source": 25,
}
},
{
"_index": "ew_mark",
"_type": "ew_mark",
"_id": "16026",
"_score": 20,
"_source": {
"id": 16026,
"markable": "119",
"annotable": "annotable-1",
"source": 25,
}
},
{
"_index": "ew_mark",
"_type": "ew_mark",
"_id": "16027",
"_score": 20,
"_source": {
"id": 16027,
"markable": "119",
"annotable": "annotable-1",
"source": 25,
}
},
{
"_index": "ew_mark",
"_type": "ew_mark",
"_id": "16028",
"_score": 20,
"_source": {
"id": 16028,
"markable": "119",
"annotable": "annotable-1",
"source": 25,
}
}
]
},
"aggregations": {
"by_markable": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "119",
"doc_count": 21,
"scores": {
"value": 480
}
},
{
"key": "120",
"doc_count": 20,
"scores": {
"value": 20
}
}
]
}
}
}
Мне нужна сумма scores
, чтобы быть сценарием (я пытаясь "нормализовать" их, используя logN ( оценка сценария )
, но когда я изменяю "сумму" для сценария, это дает мне ошибку. Любая подсказка?