gpt4 book ai didi

java - 如何在 ElasticSearch 上使用带有 JAVA API 的 hasChildFilter

转载 作者:行者123 更新时间:2023-11-30 09:10:53 25 4
gpt4 key购买 nike

我正在尝试使用 geoBoundingBowFilter 发出地理定位请求。这是完美的工作。我的地理位置与其他对象有父子关系。我想让这个对象有我的 geoFilter 而不是地理定位的响应。我正在尝试使用 hasChildFilter,但我的响应命中率始终为零。

这是我正在使用的代码:

SearchResponse response = client.prepareSearch(index)
.setTypes(type)
.setSearchType(SearchType.QUERY_THEN_FETCH)
.setQuery(QueryBuilders.matchAllQuery())
.setPostFilter(FilterBuilders.hasChildFilter("location", FilterBuilders.geoBoundingBoxFilter("point")
.topLeft(topLeftLatitude, topLeftLongitude)
.bottomRight(bottomRightLatitude, bottomRightLongitude)))
.execute()
.actionGet();
return response;

提前致谢。

最佳答案

解决方案实际上非常简单,我在 haschildFilter 之前停止执行 query.matchall()。我的功能现在是这样的:

    SearchResponse response = client
.prepareSearch(index)
.setPostFilter( FilterBuilders.hasChildFilter(type,FlterBuilders
.geoBoundingBoxFilter("point")
.bottomRight(bottomRightLatitude,bottomRightLongitude)
.topLeft(topLeftLatitude,topLeftLongitude))).execute()
.actionGet();

希望对大家有所帮助。

关于java - 如何在 ElasticSearch 上使用带有 JAVA API 的 hasChildFilter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22330299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com