collopse
{ "size":3, "query":{ "more_like_this":{ "fields" : ["remark"], "like" : ["特价","套装" ], "min_term_freq" : 1, "max_query_terms" : 1 } } , "collapse" : { "field" : "userid.keyword" }, "_source":["userid"], "sort": { "time": "asc" } }
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder(); sourceBuilder.query(query); sourceBuilder.collapse(new CollapseBuilder("userid.keyword")); sourceBuilder.from(pagesize * pageindex); sourceBuilder.size(pagesize); sourceBuilder.fetchSource(new String[] { "userid" }, new String[] {}); sourceBuilder.sort("time", SortOrder.DESC);