我正在使用elastic4s 1.5.10,并试图构建一个在弹性REST端点上准备的查询。现在试图重写到elastic4s dsl。
POST /index_name/type/_search
{
"_source":{"include":["name","surname"]},
"query": {
"bool": {
"must": [
{
"more_like_this": {
"fields": ["desc"],
"ids": ["472825948"],
"min_term_freq":0,
"max_query_terms":200
}
},
{
"match": {"city": "London"}
},
{
"match": {"operation": "add"}
}
]
}
}
}此查询的目标是获取与472825948相似的项,后者在同一城市(伦敦)具有相同的操作(add)。
我在elastic4s中的尝试如下:
es_client.execute{
search in s"$storage_folder/${typ.name()}" query bool(
must(
morelike id adId in s"$storage_folder/${typ.name()}" fields("desc") minTermFreq(0) maxQueryTerms(200),
matchQuery(field="city",value = "London"),
matchQuery(field="operation",value = "add"))
)sourceInclude("name","surname")
}
}“更像”在这种情况下是行不通的。如果查询在原始json中没有意义,或者elastic4s不支持这一点,或者.
有人能帮忙吗?
Thx
发布于 2015-06-02 07:26:57
为了完整,添加响应,我也到了这里。morelikee表示请求类型,morelikeThisQuery是查询的正确形式。因此,结果的查询应该如下所示
es_client.execute{
search in s"$storage_folder/${typ.name()}" query bool(
must(
morelikeThisQuery fields("desc") ids(adId) minTermFreq(0) maxQueryTerms(200),
matchQuery(field="city",value = "London"),
matchQuery(field="operation",value = "add"))
)sourceInclude("name","surname")
}
}https://stackoverflow.com/questions/30577140
复制相似问题