Java API for distance_feature in Elastic Search



我正在尝试使用弹性搜索distance_feature为日期和地理位置字段实现相关性提升。什么Java API对应于distance_feature查询?

以下查询在 Kibana 上工作正常:

{
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "mountain",
"fields": [
"description$string"
]
}
},
{
"bool": {
"should": [
{
"distance_feature": {
"field": "location$location",
"pivot": "1km",
"origin": [
-35.58,20.4
],
"boost": 1
}
},
{
"distance_feature": {
"field": "date_established$date",
"pivot": "10d",
"origin": "now",
"boost": 10
}
}
]
}
}
]
}
},
"_source": {
"includes": [
"title$string",
"location$location",
"date_established$date"
]
}
}```
I do not want to use the decay function for this case.

您可以使用DistanceFeatureQueryBuilder类:

对于地理点:

GeoPoint geo = new GeoPoint(-35.58, 20.4);
DistanceFeatureQueryBuilder.Origin origin = new DistanceFeatureQueryBuilder.Origin(geo);
DistanceFeatureQueryBuilder dfqb = new DistanceFeatureQueryBuilder("location$location", origin, "1km")

对于日期:

Origin origin = new Origin("now");
DistanceFeatureQueryBuilder dfqb = new DistanceFeatureQueryBuilder("date_established$date", origin, "10d")

我已经提出了一个问题,要求在QueryBuilders中添加用于distance_feature的工厂方法。

相关内容

  • 没有找到相关文章

最新更新