我一直在使用Elastic
DSLQuerySearch
和RestHighLevelClient
,发现DSLQuerySearch
的结果比RestHighLevelClient
更好,更具体。我想念什么吗?共享不同的代码
DSLQuerySearch
String result = a.executeDSLQuerySearch(
INDEX
+ "/"
+ TYPE
+ "/_search?pretty&filter_path=hits.hits._source&_source=field1,field2,field3",
searchQuery
);
与RestHighLevelClient
SearchRequest searchRequest = new SearchRequest(INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.fetchSource(includeFields, excludeFields);
/* Choose field match or matchAllQuery. */
searchSourceBuilder.query(QueryBuilders.multiMatchQuery(query, "field1", "field2", "field3"));
searchSourceBuilder.query(geoDistanceQuery("geo")
.geohash(geoHash)
.distance(Constants.MAX_Q_SEARCH_DISTANCE, DistanceUnit.KILOMETERS));
searchSourceBuilder.sort(new GeoDistanceSortBuilder("geo", geoHash).order(SortOrder.DESC));
searchSourceBuilder.size(PaginationEnum.TEN.getLimit());
searchRequest.source(searchSourceBuilder);
searchRequest.scroll(TimeValue.timeValueMinutes(MINUTES));
searchResponse = a.restHighLevelClient().search(searchRequest, RequestOptions.DEFAULT);
我期望的结果更加具体。 RestHighLevelClient
给出非常通用的结果。 (阅读更多无关的内容),而DSLQuerySearch
不在现场。