查询时如何将参数传递给相似脚本函数

问题描述 投票:0回答:1

在配对匹配中,公式2 *对配对/联合对* 100 ex:santhoshi在弹性索引文档值中,santhosh在查询中是searchin元素,然后在santhoshi = 8中没有配对,no.of pair匹配= 7,santhosh中的对没有= 7结果= 2 * 7 /(7_8)* 100 = 93%......我尝试了以下代码获取归档.sumDocFreq是“type”:“illegal_argument_exception,”reason“ :“未定义变量[字段]。”

{ "query": {
        "function_score": {
             "query": {
              "match": {
                "Name":"santhosh"
              }
            },
             "min_score":100,
            "functions": [
                {
                    "script_score": {
                         "script": {
                        "params" : {
                            "inputpairlength": 6 },
                        "source": "double tf = doc.freq; double ttf = field.sumDocFreq;  return (2* tf /(params.inputpairlength + ttf)) * 100;"
                         }
                    }
                }
            ]
        }
    }

}

 "settings": {
      "similarity": {
      "scripted_tfidf": {
        "type": "scripted",
        "script": {
          "source": "double tf = doc.freq; double ttf = field.sumDocFreq;  return  tf / (params.inputpairlength+ttf) * 100;"
        }
      }
    },
getting param.input is not defined


I need to pass parameter and calcluate score using  this "double tf = doc.freq; double ttf = field.sumDocFreq;  return  tf / (params.inputpairlength+ttf) * 100
elasticsearch
1个回答
0
投票

这是访问现场统计数据的错误方法。访问字段统计 -

_index [ '领域']。docCount()

你可以在这里阅读更多相关信息 - Elastic Guide

© www.soinside.com 2019 - 2024. All rights reserved.