我目前正在尝试使用elasticsearch的Java API构建此功能评分查询:
"query": {
"function_score": {
"query": {
"query_string": {
"query": " ( ((Feild1:\"KeyWord\"^100) OR (Feild2:\"KeyWord\"^50) ))",
"default_operator": "and"
}
},
"boost_mode": "replace",
"script_score": {
"script": "_score * doc [ 'calc_feild'].value"
}
}
但是我找不到任何关于java api和函数分数查询的文档。这就是我到目前为止所做的:
到目前为止,我意识到了它
searchParam = ((Feild1:\"KeyWord\"^100) OR (Feild2:\"KeyWord\"^50))
searchBulider.setQuery(new FunctionScoreQueryBuilder(QueryBuilders.queryString(searchParam).defaultOperator(Operator.AND)).boostMode("replace"));
查询
"query" : {
"function_score" : {
"query" : {
"query_string" : {
"query" : " ( ((Feild1:\"KeyWord\"^100) OR (Feild2:\"KeyWord\"^50) ) )",
"default_operator" : "and"
}
},
"functions" : [ ],
"boost_mode" : "replace"
}
我不知道将来的方法 接下来的问题是我如何在FunctionScore Builder中为函数提供
功能为空?
谢谢
答案 0 :(得分:2)
你是正确的方式,这是构建所需查询的完整代码:
include Voltaire