elasticsearch折叠字段collapse的使用

queryDsl地址:https://elasticsearch.cn/article/132

注:可以直接看 倒数第5个代码块

java的restclient实现方式

SearchRequest searchRequest = new SearchRequest("xxx(index)");
        SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
        sourceBuilder.from(0);
        sourceBuilder.size(1000);
        //必须是keyword类型
        sourceBuilder.collapse(new CollapseBuilder("user_id.keyword"));
        searchRequest.source(sourceBuilder);
        SearchResponse search = restClient.getRestHighLevelClient().search(searchRequest);

你可能感兴趣的:(资源,elasticsearch,collapse)