|
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -32,11 +33,26 @@ public class TermsCountAnalysisBuilder implements IEsCountAnalysisBuilder {
|
|
public Aggregation createCountAnalyseAgg() throws Exception {
|
|
public Aggregation createCountAnalyseAgg() throws Exception {
|
|
Aggregation aggregation = null;
|
|
Aggregation aggregation = null;
|
|
if (StringUtils.isNotEmpty(valueOne)) {
|
|
if (StringUtils.isNotEmpty(valueOne)) {
|
|
- String str = "*";
|
|
|
|
- String s = str.concat(valueOne).concat("*");
|
|
|
|
- Query query = QueryBuilders.wildcard(i -> i.field(field).value(s));
|
|
|
|
|
|
+ Query query = null;
|
|
|
|
+ if (valueOne.contains("罒")) {
|
|
|
|
+ String[] split = valueOne.split("罒");
|
|
|
|
+ List<String> list = Arrays.asList(split);
|
|
|
|
+ List<Query> queries = new ArrayList<>();
|
|
|
|
+ for (String value : list) {
|
|
|
|
+ String str = "*";
|
|
|
|
+ String s = str.concat(value).concat("*");
|
|
|
|
+ Query q = QueryBuilders.wildcard(i -> i.field(field).value(s));
|
|
|
|
+ queries.add(q);
|
|
|
|
+ }
|
|
|
|
+ query = QueryBuilders.bool(i -> i.should(queries));
|
|
|
|
+ } else {
|
|
|
|
+ String str = "*";
|
|
|
|
+ String s = str.concat(valueOne).concat("*");
|
|
|
|
+ query = QueryBuilders.wildcard(i -> i.field(field).value(s));
|
|
|
|
+ }
|
|
Aggregation term = AggregationBuilders.terms(j -> j.field(field).size(topN));
|
|
Aggregation term = AggregationBuilders.terms(j -> j.field(field).size(topN));
|
|
- aggregation = new Aggregation.Builder().filter(i -> i.bool(j -> j.must(query))).aggregations(new HashMap() {{
|
|
|
|
|
|
+ Query finalQuery = query;
|
|
|
|
+ aggregation = new Aggregation.Builder().filter(i -> i.bool(j -> j.must(finalQuery))).aggregations(new HashMap() {{
|
|
put("filter_agg", term);
|
|
put("filter_agg", term);
|
|
}}).build();
|
|
}}).build();
|
|
} else if (!CollectionUtils.isEmpty(values)) {
|
|
} else if (!CollectionUtils.isEmpty(values)) {
|