|
@@ -127,7 +127,8 @@ public class EsQueryServiceImpl implements EsQueryService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Object> query(List<EsQueryText> queryList, List<ComparisonResult> limiters, int page, int limit) {
|
|
|
+ public Map<String, Object> query(List<EsQueryText> queryList, List<ComparisonResult> limiters,
|
|
|
+ int page, int limit, String orderType, String orderBy) {
|
|
|
//[1]需要返回的结果map
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
result.put("total", 0);
|
|
@@ -184,12 +185,14 @@ public class EsQueryServiceImpl implements EsQueryService {
|
|
|
boolQuery.should(queryMustList);
|
|
|
}
|
|
|
Query queryMust = Query.of(q -> q.bool(boolQuery.build()));
|
|
|
- //Query byName = MatchQuery.of(m -> m.field("well_common_name").query("宁12-412"))._toQuery();
|
|
|
- //Query queryMust = Query.of(q -> q.term(TermQuery.of(m -> m.field("well_common_name.keyword").value("宁12-412"))));
|
|
|
- SortOptions.Builder sb = new SortOptions.Builder();
|
|
|
- sb.field(f -> f.field("create_date").order(SortOrder.Desc));
|
|
|
- searchRequest.query(queryMust).sort(sb.build());
|
|
|
|
|
|
+ if (orderType != null && !StringUtils.IsNullEmpty(orderBy)) {
|
|
|
+ SortOptions.Builder sb = new SortOptions.Builder();
|
|
|
+ sb.field(f -> f.field(orderBy).order(orderType.equals("asc") ? SortOrder.Asc : SortOrder.Desc));
|
|
|
+ searchRequest.query(queryMust).sort(sb.build());
|
|
|
+ }else{
|
|
|
+ searchRequest.query(queryMust);
|
|
|
+ }
|
|
|
//==>高亮设置
|
|
|
searchRequest.highlight(h -> h.fields("*", f -> f.preTags("<font color='red'>")
|
|
|
.postTags("</font>")));
|
|
@@ -413,7 +416,7 @@ public class EsQueryServiceImpl implements EsQueryService {
|
|
|
Map<String, Object> map = objectNode2Map(hit.index(), node);
|
|
|
map.put("index", hit.index());
|
|
|
map.put("highlight", hit.highlight());
|
|
|
- map.put("innerHits",hit.innerHits());
|
|
|
+ map.put("innerHits", hit.innerHits());
|
|
|
list.add(map);
|
|
|
|
|
|
//输出结果日志
|