我正在使用spring-boot 3.1.5和spring-data-elasticsearch 5.1.5 java项目。我尝试使用此查询编写客户端程序。
GET vector_search/_search
{
"query": {
"function_score": {
"functions": [
{
"script_score": {
"script": {
"source": "Math.max(0,cosineSimilarity(params.queryVector,'text_VEC'))",
"params": {
"queryVector": [0.1,0.1,0.0.1~~~~~~]
}
}
}
}
]
}
}
}
字符串
我的java代码是这样的。
Query searchQuery = NativeQuery.builder()
.withQuery(q -> q.scriptScore(m -> m.script(fn -> fn.inline(InlineScript.of(fn2 -> fn2.source("Math.max(0,cosineSimilarity(params.queryVector,'text_VEC'))"))))))
.withQuery(q -> q.scriptScore(m -> m.script(fn -> fn.inline(InlineScript.of(fn2 -> fn2.params(params))))))
.withMaxResults(5)
.build();
型
但是我得到了这个异常。co. elastic. clients. util. MissingRedPropertyException:在co. elastic. clients. util. ApiTypeHelper. requireNonError处缺少必需的属性"ScriptScoreQuery. query "(ApiTypeHelper.java:在co.elastic.clients.elasticsearch._types. query_dsl.ScriptScoreQuery中找到。(ScriptScoreQuery.java:63)位于co.elastic.clients.elasticsearch._types. query_dsl.ScriptScoreQuery。(ScriptScoreQuery.java:49)位于co.elastic.clients.elasticsearch._types. query_query. ScriptScoreQuery $www.example.com(ScriptScoreQuery.java:在co.elastic.clients.elasticsearch._types. query_credit. ScriptScoreQuery $www.example.com上搜索(ScriptScoreQuery.java:124)at co.elastic.clients.elasticsearch._types. query_query. Query $Builder. scriptScore(Query.java:1601)
我错过了什么?
C
1条答案
按热度按时间byqmnocz1#
如错误所述,
在以下位置缺少必需的属性“ScriptScoreQuery.query "
script_score
查询要求您specify aquery
字符串
因此,您还需要在
型