I am trying to use cosineSimilarity function inside in aggregation script but getting
Unknown call [cosine Similarity] with [2] arguments
{
"query": {
"match_all": {}
},
"aggs": {
"group": {
"terms": {
"field": "group"
},
"aggs": {
"profit": {
"scripted_metric": {
"params": {
"que_vec": [1,2,3], "ans_vec": [3,4,5]
},
"init_script": "state.scores = [:]",
"map_script": "double score = 0; if (doc.type.value == 'question') { score = cosineSimilarity(params.que_vec, doc.vector) } else { score = cosineSimilarity(params.ans_vec, doc.vector) } if (score > state.scores.getOrDefault(doc.type.value, 0)) { state.scores[doc.type.value] = score }",
"combine_script": "return state.scores",
"reduce_script": "return states"
}
}
}
}
}
}