有用的链接:http://stackoverflow.com/questions/12215380/sorting-on-several-fields-in-elasticsearch
有的时候,需要自己设定排序,java的一个接口如下:
String time1 = ConstValue.GetCurrentDate(); SortBuilder sortBuilder = SortBuilders.fieldSort("tfp_save_time") .order(SortOrder.DESC).ignoreUnmapped(true); SearchResponse scrollResp = client .prepareSearch("flume-" + time1 + "-content-news") .addHighlightedField("scc_content") .addHighlightedField("scm_title") .setQuery(ConstValue.queryBuilder22(requestSignal.getQuery())) .addSort(sortBuilder).addHighlightedField("scc_title") .setHighlighterPreTags("<em>").setHighlighterPostTags("</em>") .setFrom((requestSignal.getPage() - 1) * 20).setSize(20) .execute().actionGet();