mirror of
https://gitee.com/dromara/easy-es.git
synced 2025-12-07 17:48:42 +08:00
v2.0-beta2
优化banner显示,针对所有长度的版本号,做了更友好的展示效果 修复multiMatch中minShouldMatch参数没有自动添加百分号的缺陷 修复四大嵌套类型算法在一些特殊复杂场景下不能正确还原lambda表达式的缺陷 修复距离字段在指定多个排序器且首个排序器不是按距离排时不能正确返回距离的缺陷
This commit is contained in:
parent
b680f83eab
commit
c944b77d36
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.easy-es</groupId>
|
<groupId>cn.easy-es</groupId>
|
||||||
<artifactId>easy-es-parent</artifactId>
|
<artifactId>easy-es-parent</artifactId>
|
||||||
<version>2.0.0-beta1</version>
|
<version>2.0.0-beta2</version>
|
||||||
<relativePath>../easy-es-parent</relativePath>
|
<relativePath>../easy-es-parent</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easy-es-parent</artifactId>
|
<artifactId>easy-es-parent</artifactId>
|
||||||
<groupId>cn.easy-es</groupId>
|
<groupId>cn.easy-es</groupId>
|
||||||
<version>2.0.0-beta1</version>
|
<version>2.0.0-beta2</version>
|
||||||
<relativePath>../easy-es-parent</relativePath>
|
<relativePath>../easy-es-parent</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@ -56,7 +56,18 @@ public class MapperScannerRegister implements ImportBeanDefinitionRegistrar, Res
|
|||||||
"\"`-0-0-'\"`-0-0-'\"`-0-0-'\"`-0-0-'\"`-0-0-'\"`-0-0-'\"`-0-0-'\n" +
|
"\"`-0-0-'\"`-0-0-'\"`-0-0-'\"`-0-0-'\"`-0-0-'\"`-0-0-'\"`-0-0-'\n" +
|
||||||
"------------------------------------------------------>"
|
"------------------------------------------------------>"
|
||||||
);
|
);
|
||||||
System.out.println(":: version :: " + versionStr + " >");
|
|
||||||
|
// 版本长度并不固定,比如beta版,所以需要特殊处理
|
||||||
|
int width = 38;
|
||||||
|
int blank = width - versionStr.length();
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(":: version :: ")
|
||||||
|
.append(versionStr);
|
||||||
|
for (int i = 0; i < blank; i++) {
|
||||||
|
sb.append(" ");
|
||||||
|
}
|
||||||
|
sb.append(">");
|
||||||
|
System.out.println(sb);
|
||||||
System.out.println(":: home :: https://easy-es.cn/ >");
|
System.out.println(":: home :: https://easy-es.cn/ >");
|
||||||
System.out.println(":: community :: https://dromara.org/ >");
|
System.out.println(":: community :: https://dromara.org/ >");
|
||||||
System.out.println(":: wechat :: 252645816, add and become muscle man! >");
|
System.out.println(":: wechat :: 252645816, add and become muscle man! >");
|
||||||
@ -88,4 +99,8 @@ public class MapperScannerRegister implements ImportBeanDefinitionRegistrar, Res
|
|||||||
public void setEnvironment(Environment environment) {
|
public void setEnvironment(Environment environment) {
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("252645816, add and become muscle man! >".length());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.easy-es</groupId>
|
<groupId>cn.easy-es</groupId>
|
||||||
<artifactId>easy-es-parent</artifactId>
|
<artifactId>easy-es-parent</artifactId>
|
||||||
<version>2.0.0-beta1</version>
|
<version>2.0.0-beta2</version>
|
||||||
<relativePath>../easy-es-parent</relativePath>
|
<relativePath>../easy-es-parent</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@ -55,6 +55,10 @@ public interface BaseEsConstants {
|
|||||||
* 冒号
|
* 冒号
|
||||||
*/
|
*/
|
||||||
String COLON = ":";
|
String COLON = ":";
|
||||||
|
/**
|
||||||
|
* 百分号
|
||||||
|
*/
|
||||||
|
String PERCENT_SIGN = "%";
|
||||||
/**
|
/**
|
||||||
* ee内置es分布式锁索引名称
|
* ee内置es分布式锁索引名称
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public class EEVersionUtils {
|
|||||||
*/
|
*/
|
||||||
public static <T> String getJarVersion(Class<T> objectClass) {
|
public static <T> String getJarVersion(Class<T> objectClass) {
|
||||||
return Optional.ofNullable(objectClass.getPackage().getImplementationVersion()).
|
return Optional.ofNullable(objectClass.getPackage().getImplementationVersion()).
|
||||||
orElse(UNKNOWN);
|
orElse("UNKNOWN");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.easy-es</groupId>
|
<groupId>cn.easy-es</groupId>
|
||||||
<artifactId>easy-es-parent</artifactId>
|
<artifactId>easy-es-parent</artifactId>
|
||||||
<version>2.0.0-beta1</version>
|
<version>2.0.0-beta2</version>
|
||||||
<relativePath>../easy-es-parent</relativePath>
|
<relativePath>../easy-es-parent</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import cn.easyes.core.biz.Param;
|
|||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询Lambda表达式
|
* 查询Lambda表达式
|
||||||
@ -31,14 +32,14 @@ public class LambdaEsQueryWrapper<T> extends AbstractLambdaQueryWrapper<T, Lambd
|
|||||||
}
|
}
|
||||||
|
|
||||||
LambdaEsQueryWrapper(T entity, int level, String parentId, EsQueryTypeEnum pervQueryType, LinkedList<Param> paramList,
|
LambdaEsQueryWrapper(T entity, int level, String parentId, EsQueryTypeEnum pervQueryType, LinkedList<Param> paramList,
|
||||||
LinkedList<String> parentIdQueue, LinkedList<EsQueryTypeEnum> prevQueryTypeQueue,
|
Stack<String> parentIdStack, LinkedList<EsQueryTypeEnum> prevQueryTypeQueue,
|
||||||
List<BaseSortParam> baseSortParams, List<AggregationParam> aggregationParamList) {
|
List<BaseSortParam> baseSortParams, List<AggregationParam> aggregationParamList) {
|
||||||
super.setEntity(entity);
|
super.setEntity(entity);
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
this.prevQueryType = pervQueryType;
|
this.prevQueryType = pervQueryType;
|
||||||
this.paramQueue = paramList;
|
this.paramQueue = paramList;
|
||||||
this.parentIdQueue = parentIdQueue;
|
this.parentIdStack = parentIdStack;
|
||||||
this.prevQueryTypeQueue = prevQueryTypeQueue;
|
this.prevQueryTypeQueue = prevQueryTypeQueue;
|
||||||
this.baseSortParams = baseSortParams;
|
this.baseSortParams = baseSortParams;
|
||||||
this.aggregationParamList = aggregationParamList;
|
this.aggregationParamList = aggregationParamList;
|
||||||
@ -46,7 +47,7 @@ public class LambdaEsQueryWrapper<T> extends AbstractLambdaQueryWrapper<T, Lambd
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LambdaEsQueryWrapper<T> instance() {
|
protected LambdaEsQueryWrapper<T> instance() {
|
||||||
return new LambdaEsQueryWrapper<>(entity, level, parentId, prevQueryType, paramQueue, parentIdQueue, prevQueryTypeQueue, baseSortParams, aggregationParamList);
|
return new LambdaEsQueryWrapper<>(entity, level, parentId, prevQueryType, paramQueue, parentIdStack, prevQueryTypeQueue, baseSortParams, aggregationParamList);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import cn.easyes.core.conditions.function.Update;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新Lambda表达式
|
* 更新Lambda表达式
|
||||||
@ -33,20 +34,20 @@ public class LambdaEsUpdateWrapper<T> extends AbstractLambdaUpdateWrapper<T, Lam
|
|||||||
}
|
}
|
||||||
|
|
||||||
LambdaEsUpdateWrapper(T entity, int level, String parentId, EsQueryTypeEnum pervQueryType, LinkedList<Param> paramQueue,
|
LambdaEsUpdateWrapper(T entity, int level, String parentId, EsQueryTypeEnum pervQueryType, LinkedList<Param> paramQueue,
|
||||||
LinkedList<String> parentIdQueue, LinkedList<EsQueryTypeEnum> prevQueryTypeQueue, List<EsUpdateParam> updateParamList) {
|
Stack<String> parentIdStack, LinkedList<EsQueryTypeEnum> prevQueryTypeQueue, List<EsUpdateParam> updateParamList) {
|
||||||
super.setEntity(entity);
|
super.setEntity(entity);
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
this.prevQueryType = pervQueryType;
|
this.prevQueryType = pervQueryType;
|
||||||
this.paramQueue = paramQueue;
|
this.paramQueue = paramQueue;
|
||||||
this.parentIdQueue = parentIdQueue;
|
this.parentIdStack = parentIdStack;
|
||||||
this.prevQueryTypeQueue = prevQueryTypeQueue;
|
this.prevQueryTypeQueue = prevQueryTypeQueue;
|
||||||
this.updateParamList = updateParamList;
|
this.updateParamList = updateParamList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LambdaEsUpdateWrapper<T> instance() {
|
protected LambdaEsUpdateWrapper<T> instance() {
|
||||||
return new LambdaEsUpdateWrapper<>(entity, level, parentId, prevQueryType, paramQueue, parentIdQueue, prevQueryTypeQueue, updateParamList);
|
return new LambdaEsUpdateWrapper<>(entity, level, parentId, prevQueryType, paramQueue, parentIdStack, prevQueryTypeQueue, updateParamList);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,9 +53,9 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
|
|||||||
*/
|
*/
|
||||||
protected EsQueryTypeEnum prevQueryType;
|
protected EsQueryTypeEnum prevQueryType;
|
||||||
/**
|
/**
|
||||||
* 队列 存放父id
|
* 栈 存放父id
|
||||||
*/
|
*/
|
||||||
protected LinkedList<String> parentIdQueue;
|
protected Stack<String> parentIdStack;
|
||||||
/**
|
/**
|
||||||
* 队列 存放上一节点类型
|
* 队列 存放上一节点类型
|
||||||
*/
|
*/
|
||||||
@ -92,7 +92,7 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
|
|||||||
aggregationParamList = new ArrayList<>();
|
aggregationParamList = new ArrayList<>();
|
||||||
paramQueue = new LinkedList<>();
|
paramQueue = new LinkedList<>();
|
||||||
prevQueryType = NESTED_AND;
|
prevQueryType = NESTED_AND;
|
||||||
parentIdQueue = new LinkedList<>();
|
parentIdStack = new Stack<>();
|
||||||
prevQueryTypeQueue = new LinkedList<>();
|
prevQueryTypeQueue = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,17 +709,22 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
|
|||||||
|
|
||||||
paramQueue.add(param);
|
paramQueue.add(param);
|
||||||
this.parentId = param.getId();
|
this.parentId = param.getId();
|
||||||
parentIdQueue.push(parentId);
|
parentIdStack.push(parentId);
|
||||||
level++;
|
level++;
|
||||||
consumer.accept(instance());
|
consumer.accept(instance());
|
||||||
// 深度优先在consumer条件消费完后会来执行这里 此时parentId需要重置 至于为什么,比较烧脑 可断点打在consumer前后观察一波
|
// 深度优先在consumer条件消费完后会来执行这里 此时parentId需要重置 至于为什么,比较烧脑 可断点打在consumer前后观察一波
|
||||||
level--;
|
level--;
|
||||||
if (!parentIdQueue.isEmpty()) {
|
if (!parentIdStack.isEmpty()) {
|
||||||
this.parentId = parentIdQueue.pollLast();
|
// 丢弃栈顶 当前id
|
||||||
}
|
parentIdStack.pop();
|
||||||
if (level == 0) {
|
|
||||||
|
if (parentIdStack.isEmpty()) {
|
||||||
// 仙人板板 根节点
|
// 仙人板板 根节点
|
||||||
this.parentId = null;
|
parentId = null;
|
||||||
|
} else {
|
||||||
|
// 非根节点 取其上一节点id作为爸爸id
|
||||||
|
this.parentId = parentIdStack.peek();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1066,11 +1066,11 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
|||||||
for (int i = 0; i < sortValues.length; i++) {
|
for (int i = 0; i < sortValues.length; i++) {
|
||||||
Object sortValue = sortValues[i];
|
Object sortValue = sortValues[i];
|
||||||
if (!(sortValue instanceof Double)) {
|
if (!(sortValue instanceof Double)) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
double distance = (double) sortValue;
|
double distance = (double) sortValue;
|
||||||
if (Double.isNaN(distance)) {
|
if (Double.isNaN(distance)) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
Integer distanceDecimalPlaces = entityInfo.getDistanceDecimalPlaces().get(i);
|
Integer distanceDecimalPlaces = entityInfo.getDistanceDecimalPlaces().get(i);
|
||||||
if (distanceDecimalPlaces > ZERO) {
|
if (distanceDecimalPlaces > ZERO) {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package cn.easyes.core.core;
|
package cn.easyes.core.core;
|
||||||
|
|
||||||
|
import cn.easyes.common.constants.BaseEsConstants;
|
||||||
import cn.easyes.common.enums.AggregationTypeEnum;
|
import cn.easyes.common.enums.AggregationTypeEnum;
|
||||||
import cn.easyes.common.enums.EsQueryTypeEnum;
|
import cn.easyes.common.enums.EsQueryTypeEnum;
|
||||||
import cn.easyes.common.utils.*;
|
import cn.easyes.common.utils.*;
|
||||||
@ -125,7 +126,7 @@ public class WrapperProcessor {
|
|||||||
break;
|
break;
|
||||||
case MULTI_MATCH:
|
case MULTI_MATCH:
|
||||||
String[] realFields = getRealFields(param.getColumns(), mappingColumnMap);
|
String[] realFields = getRealFields(param.getColumns(), mappingColumnMap);
|
||||||
queryBuilder = QueryBuilders.multiMatchQuery(param.getVal(), realFields).operator((Operator) param.getExt1()).minimumShouldMatch(String.valueOf(param.getExt2()));
|
queryBuilder = QueryBuilders.multiMatchQuery(param.getVal(), realFields).operator((Operator) param.getExt1()).minimumShouldMatch(param.getExt2() + PERCENT_SIGN);
|
||||||
setBool(bool, queryBuilder, param.getPrevQueryType());
|
setBool(bool, queryBuilder, param.getPrevQueryType());
|
||||||
break;
|
break;
|
||||||
case MATCH_ALL:
|
case MATCH_ALL:
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.easy-es</groupId>
|
<groupId>cn.easy-es</groupId>
|
||||||
<artifactId>easy-es-parent</artifactId>
|
<artifactId>easy-es-parent</artifactId>
|
||||||
<version>2.0.0-beta1</version>
|
<version>2.0.0-beta2</version>
|
||||||
<relativePath>../easy-es-parent</relativePath>
|
<relativePath>../easy-es-parent</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>cn.easy-es</groupId>
|
<groupId>cn.easy-es</groupId>
|
||||||
<artifactId>easy-es-parent</artifactId>
|
<artifactId>easy-es-parent</artifactId>
|
||||||
<version>2.0.0-beta1</version>
|
<version>2.0.0-beta2</version>
|
||||||
|
|
||||||
<name>easy-es-parent</name>
|
<name>easy-es-parent</name>
|
||||||
<description>easy use for elastic search</description>
|
<description>easy use for elastic search</description>
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easy-es</artifactId>
|
<artifactId>easy-es</artifactId>
|
||||||
<groupId>cn.easy-es</groupId>
|
<groupId>cn.easy-es</groupId>
|
||||||
<version>2.0.0-beta1</version>
|
<version>2.0.0-beta2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easy-es</artifactId>
|
<artifactId>easy-es</artifactId>
|
||||||
<groupId>cn.easy-es</groupId>
|
<groupId>cn.easy-es</groupId>
|
||||||
<version>2.0.0-beta1</version>
|
<version>2.0.0-beta2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>easy-es-test</artifactId>
|
<artifactId>easy-es-test</artifactId>
|
||||||
|
|||||||
@ -38,7 +38,8 @@ public class IndexTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testCreateIndexByEntity() {
|
public void testCreateIndexByEntity() {
|
||||||
// 绝大多数场景推荐使用 简单至上
|
// 绝大多数场景推荐使用 简单至上
|
||||||
documentMapper.createIndex();
|
boolean ok = documentMapper.createIndex();
|
||||||
|
Assertions.assertTrue(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>cn.easy-es</groupId>
|
<groupId>cn.easy-es</groupId>
|
||||||
<artifactId>easy-es</artifactId>
|
<artifactId>easy-es</artifactId>
|
||||||
<version>2.0.0-beta1</version>
|
<version>2.0.0-beta2</version>
|
||||||
|
|
||||||
<name>easy-es</name>
|
<name>easy-es</name>
|
||||||
<description>easy use for elastic search</description>
|
<description>easy use for elastic search</description>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user