|
@@ -1,9 +1,11 @@
|
|
package cn.cslg.pas.factorys.EsCountAnalyseBuilderFactory;
|
|
package cn.cslg.pas.factorys.EsCountAnalyseBuilderFactory;
|
|
|
|
|
|
|
|
+import co.elastic.clients.elasticsearch._types.SortOrder;
|
|
import co.elastic.clients.elasticsearch._types.aggregations.*;
|
|
import co.elastic.clients.elasticsearch._types.aggregations.*;
|
|
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
|
|
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
|
|
import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
|
|
import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
|
|
import co.elastic.clients.json.JsonData;
|
|
import co.elastic.clients.json.JsonData;
|
|
|
|
+import co.elastic.clients.util.NamedValue;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -56,7 +58,7 @@ public class ChildCountAnalysisBuilder implements IEsCountAnalysisBuilder {
|
|
.gte(JsonData.of(valueOne)).lte(JsonData.of(valueTwo)));
|
|
.gte(JsonData.of(valueOne)).lte(JsonData.of(valueTwo)));
|
|
queryList.add(query);
|
|
queryList.add(query);
|
|
}
|
|
}
|
|
- Aggregation terms = AggregationBuilders.terms(i -> i.field("custom_field.stats_value.raw").size(topN));
|
|
|
|
|
|
+ Aggregation terms = AggregationBuilders.terms(i -> i.field("custom_field.stats_value.raw").order(NamedValue.of("_key",SortOrder.Desc)).size(topN));
|
|
termAgg = new Aggregation.Builder().filter(n -> n.bool(k -> k.must(queryList)))
|
|
termAgg = new Aggregation.Builder().filter(n -> n.bool(k -> k.must(queryList)))
|
|
.aggregations(new HashMap() {{
|
|
.aggregations(new HashMap() {{
|
|
put("filterAgg", terms);
|
|
put("filterAgg", terms);
|
|
@@ -77,7 +79,7 @@ public class ChildCountAnalysisBuilder implements IEsCountAnalysisBuilder {
|
|
.gte(JsonData.of(valueOne)).lte(JsonData.of(valueTwo)));
|
|
.gte(JsonData.of(valueOne)).lte(JsonData.of(valueTwo)));
|
|
queryList.add(query);
|
|
queryList.add(query);
|
|
}
|
|
}
|
|
- Aggregation terms = AggregationBuilders.terms(i -> i.field("custom_field.field_value.raw").size(topN));
|
|
|
|
|
|
+ Aggregation terms = AggregationBuilders.terms(i -> i.field("custom_field.field_value.raw").order(NamedValue.of("_key",SortOrder.Desc)).size(topN));
|
|
termAgg = new Aggregation.Builder().filter(n -> n.bool(k -> k.must(queryList)))
|
|
termAgg = new Aggregation.Builder().filter(n -> n.bool(k -> k.must(queryList)))
|
|
.aggregations(new HashMap() {{
|
|
.aggregations(new HashMap() {{
|
|
put("filterAgg", terms);
|
|
put("filterAgg", terms);
|