我在索引“名称”中包含带有字符串数组的字段:[“ Nirav Modi”,“ Modi Nirav”] 并应用bigram令牌生成器和过滤器。需要自定义分数,配对数不匹配。脚本分数在设置时被索引,如下所示 “相似性”:{ “ scripted_tfidf”:{ “ type”:“ scripted”, “脚本”:{ “ source”:“ double tf = doc.freq; return 2 * tf” } } }
GET /negativelistwitharrayobj/details/_search?explain=true
{
"query": {
"bool": {
"must": [
{
"function_score": {
"query": {
"nested": {
"path": "PenNames",
"query": {
"match": { "PenNames.Name": "nirav" }
}
}
},
"functions": [
{
"script_score": {
"script": {
"source": "(_score)"
}
}
}
]
}
}
]
}
} }
问题是“ nirav”,二元组对是ni,ir,ra,av,那么Nirav Modi的结果是16,因为nirav在数组中存在2次
我希望分数应为8->(2 * 4)仅考虑单个元素,而不考虑数组字段中的所有元素