|
@@ -53,6 +53,7 @@ public class EsQueryServiceImpl implements EsQueryService {
|
|
private static Object lockObject = new Object();
|
|
private static Object lockObject = new Object();
|
|
private static List<String> indexCache = null;
|
|
private static List<String> indexCache = null;
|
|
private static List<String> pathCache = null;
|
|
private static List<String> pathCache = null;
|
|
|
|
+ private static List<EsIndexfieldVo> indexFields = null;
|
|
private static long cacheTime = 0;
|
|
private static long cacheTime = 0;
|
|
|
|
|
|
public void getCacheList() {
|
|
public void getCacheList() {
|
|
@@ -66,6 +67,9 @@ public class EsQueryServiceImpl implements EsQueryService {
|
|
.distinct().collect(Collectors.toList());
|
|
.distinct().collect(Collectors.toList());
|
|
|
|
|
|
List<EsIndexfieldVo> list2 = esIndexCquery.getFieldList(null, null);
|
|
List<EsIndexfieldVo> list2 = esIndexCquery.getFieldList(null, null);
|
|
|
|
+
|
|
|
|
+ indexFields= list2.stream().filter(p -> !p.getDataType().equals("NESTED")).collect(Collectors.toList());
|
|
|
|
+
|
|
pathCache = list2.stream().filter(p -> p.getDataType().equals("NESTED"))
|
|
pathCache = list2.stream().filter(p -> p.getDataType().equals("NESTED"))
|
|
.map(m -> m.getFieldCode())
|
|
.map(m -> m.getFieldCode())
|
|
.distinct().collect(Collectors.toList());
|
|
.distinct().collect(Collectors.toList());
|
|
@@ -318,9 +322,15 @@ public class EsQueryServiceImpl implements EsQueryService {
|
|
query = QueryBuilders.rangeQuery(fieldString).lt(value);
|
|
query = QueryBuilders.rangeQuery(fieldString).lt(value);
|
|
else if (opreation.equals("小于等于"))
|
|
else if (opreation.equals("小于等于"))
|
|
query = QueryBuilders.rangeQuery(fieldString).lte(value);
|
|
query = QueryBuilders.rangeQuery(fieldString).lte(value);
|
|
- else if (opreation.equals("等于"))
|
|
|
|
- query = QueryBuilders.termQuery(fieldString+".keyword", value);
|
|
|
|
- else if (opreation.equals("包括IN")) {
|
|
|
|
|
|
+ else if (opreation.equals("等于")) {
|
|
|
|
+ //如果是字符串类型,则使用不分词查询
|
|
|
|
+ boolean isVarchar = indexFields.stream().anyMatch(x -> x.getFieldCode().equals(fieldString) && x.getDataType().equals("VARCHAR"));
|
|
|
|
+ if(isVarchar) {
|
|
|
|
+ query = QueryBuilders.termQuery(fieldString + ".keyword", value);
|
|
|
|
+ }else {
|
|
|
|
+ query = QueryBuilders.termQuery(fieldString, value);
|
|
|
|
+ }
|
|
|
|
+ }else if (opreation.equals("包括IN")) {
|
|
String[] fls = value.split(",");
|
|
String[] fls = value.split(",");
|
|
query=QueryBuilders.termsQuery(fieldString, fls);
|
|
query=QueryBuilders.termsQuery(fieldString, fls);
|
|
}
|
|
}
|