ElasticSearch排序Java api简单Demo

代码:

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

官方粘的:

client.prepareSearch(indexName).setTypes(typeName)
.setQuery(query)
.addSort(fieldSort("activity").order(DESC).missing("_last"))
.setSize(limit)
.execute().actionGet();

The .missing("_last") cannot be applied to boolean fields.

上一篇:MyBatis核心接口和类


下一篇:TOP100summit 2017 七牛云许式伟:不用JAVA和C语言,我为什么坚持Go语言