当前位置:网站首页>Es uses collapsebuilder to de duplicate and return only a certain field

Es uses collapsebuilder to de duplicate and return only a certain field

2022-07-05 01:26:00 talen_ hx296

duplicate removal  

SearchRequest searchRequest = new SearchRequest(esIndices2.toArray(new String[esIndices2.size()]));
//  Build search criteria 
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
// Specify the de duplication field 
CollapseBuilder collapseBuilder = new CollapseBuilder("userName.keyword");
searchRequest.source(sourceBuilder.query(boolBuilder).collapse(collapseBuilder).trackTotalHits(true));

Specified field

earchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.fetchSource("userName", null)

原网站

版权声明
本文为[talen_ hx296]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050115085417.html