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);

  

posted on 2020-05-08 17:34  默西塞德  阅读(1506)  评论(0编辑  收藏  举报