Merge branch 'feature-2.1.0' of https://gitee.com/dromara/easy-es into feature-2.1.0

This commit is contained in:
xpc 2025-02-01 19:53:33 +08:00
commit 1ae845a28f
5 changed files with 120 additions and 95 deletions

View File

@ -1373,7 +1373,7 @@ public interface Compare<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children lt(R column, Object val, ZoneId timeZone, String format) { default Children lt(R column, Object val, ZoneId timeZone, String format) {
return lt(true, column, val, timeZone, format, null); return lt(true, column, val, timeZone, format, DEFAULT_BOOST);
} }
/** /**

View File

@ -9,7 +9,9 @@ import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.geometry.Geometry; import org.elasticsearch.geometry.Geometry;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.dromara.easyes.common.constants.BaseEsConstants.DEFAULT_BOOST; import static org.dromara.easyes.common.constants.BaseEsConstants.DEFAULT_BOOST;
@ -65,9 +67,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoBoundingBox(R column, String topLeft, String bottomRight) { default Children geoBoundingBox(R column, String topLeft, String bottomRight) {
GeoPoint topLeftGeoPoint = new GeoPoint(topLeft); return geoBoundingBox(true, column, topLeft, bottomRight);
GeoPoint bottomRightGeoPoint = new GeoPoint(bottomRight);
return geoBoundingBox(true, column, topLeftGeoPoint, bottomRightGeoPoint, DEFAULT_BOOST);
} }
/** /**
@ -80,9 +80,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoBoundingBox(boolean condition, R column, String topLeft, String bottomRight) { default Children geoBoundingBox(boolean condition, R column, String topLeft, String bottomRight) {
GeoPoint topLeftGeoPoint = new GeoPoint(topLeft); return geoBoundingBox(condition, FieldUtils.getFieldName(column), topLeft, bottomRight, DEFAULT_BOOST);
GeoPoint bottomRightGeoPoint = new GeoPoint(bottomRight);
return geoBoundingBox(condition, column, topLeftGeoPoint, bottomRightGeoPoint, DEFAULT_BOOST);
} }
/** /**
@ -95,9 +93,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoBoundingBox(R column, String topLeft, String bottomRight, Float boost) { default Children geoBoundingBox(R column, String topLeft, String bottomRight, Float boost) {
GeoPoint topLeftGeoPoint = new GeoPoint(topLeft); return geoBoundingBox(true, FieldUtils.getFieldName(column), topLeft, bottomRight, boost);
GeoPoint bottomRightGeoPoint = new GeoPoint(bottomRight);
return geoBoundingBox(true, column, topLeftGeoPoint, bottomRightGeoPoint, boost);
} }
/** /**
@ -147,9 +143,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoBoundingBox(String column, String topLeft, String bottomRight) { default Children geoBoundingBox(String column, String topLeft, String bottomRight) {
GeoPoint topLeftGeoPoint = new GeoPoint(topLeft); return geoBoundingBox(true, column, topLeft, bottomRight);
GeoPoint bottomRightGeoPoint = new GeoPoint(bottomRight);
return geoBoundingBox(true, column, topLeftGeoPoint, bottomRightGeoPoint, DEFAULT_BOOST);
} }
/** /**
@ -162,9 +156,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoBoundingBox(boolean condition, String column, String topLeft, String bottomRight) { default Children geoBoundingBox(boolean condition, String column, String topLeft, String bottomRight) {
GeoPoint topLeftGeoPoint = new GeoPoint(topLeft); return geoBoundingBox(true, column, topLeft, bottomRight, DEFAULT_BOOST);
GeoPoint bottomRightGeoPoint = new GeoPoint(bottomRight);
return geoBoundingBox(condition, column, topLeftGeoPoint, bottomRightGeoPoint, DEFAULT_BOOST);
} }
/** /**
@ -177,9 +169,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoBoundingBox(String column, String topLeft, String bottomRight, Float boost) { default Children geoBoundingBox(String column, String topLeft, String bottomRight, Float boost) {
GeoPoint topLeftGeoPoint = new GeoPoint(topLeft); return geoBoundingBox(true, column, topLeft, bottomRight, boost);
GeoPoint bottomRightGeoPoint = new GeoPoint(bottomRight);
return geoBoundingBox(true, column, topLeftGeoPoint, bottomRightGeoPoint, boost);
} }
/** /**
@ -208,6 +198,18 @@ public interface Geo<Children, R> extends Serializable {
*/ */
Children geoBoundingBox(boolean condition, String column, GeoPoint topLeft, GeoPoint bottomRight, Float boost); Children geoBoundingBox(boolean condition, String column, GeoPoint topLeft, GeoPoint bottomRight, Float boost);
/**
* 矩形内范围查询
*
* @param condition 执行条件
* @param column 列名 字符串
* @param topLeft 左上点坐标 GeoPoint/字符串/哈希/wkt均支持
* @param bottomRight 右下点坐标 GeoPoint/字符串/哈希/wkt均支持
* @param boost 权重值
* @return wrapper
*/
Children geoBoundingBox(boolean condition, String column, String topLeft, String bottomRight, Float boost);
/** /**
* 距离范围查询 以给定圆心和半径范围查询 距离类型为双精度 * 距离范围查询 以给定圆心和半径范围查询 距离类型为双精度
* *
@ -257,8 +259,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(R column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint) { default Children geoDistance(R column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(true, column, distance, distanceUnit, centralGeoPoint, DEFAULT_BOOST);
return geoDistance(true, column, distance, distanceUnit, geoPoint, DEFAULT_BOOST);
} }
/** /**
@ -272,8 +273,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(boolean condition, R column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint) { default Children geoDistance(boolean condition, R column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(condition, column, distance, distanceUnit, centralGeoPoint, DEFAULT_BOOST);
return geoDistance(condition, column, distance, distanceUnit, geoPoint, DEFAULT_BOOST);
} }
/** /**
@ -287,8 +287,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(R column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint, Float boost) { default Children geoDistance(R column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint, Float boost) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(true, column, distance, distanceUnit, centralGeoPoint, boost);
return geoDistance(true, column, distance, distanceUnit, geoPoint, boost);
} }
/** /**
@ -303,8 +302,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(boolean condition, R column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint, Float boost) { default Children geoDistance(boolean condition, R column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint, Float boost) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(condition, FieldUtils.getFieldName(column), distance, distanceUnit, centralGeoPoint, boost);
return geoDistance(condition, column, distance, distanceUnit, geoPoint, boost);
} }
/** /**
@ -356,8 +354,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(String column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint) { default Children geoDistance(String column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(true, column, distance, distanceUnit, centralGeoPoint, DEFAULT_BOOST);
return geoDistance(true, column, distance, distanceUnit, geoPoint, DEFAULT_BOOST);
} }
/** /**
@ -371,8 +368,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(boolean condition, String column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint) { default Children geoDistance(boolean condition, String column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(condition, column, distance, distanceUnit, centralGeoPoint, DEFAULT_BOOST);
return geoDistance(condition, column, distance, distanceUnit, geoPoint, DEFAULT_BOOST);
} }
/** /**
@ -386,8 +382,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(String column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint, Float boost) { default Children geoDistance(String column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint, Float boost) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(true, column, distance, distanceUnit, centralGeoPoint, boost);
return geoDistance(true, column, distance, distanceUnit, geoPoint, boost);
} }
/** /**
@ -401,10 +396,7 @@ public interface Geo<Children, R> extends Serializable {
* @param boost 权重值 * @param boost 权重值
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(boolean condition, String column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint, Float boost) { Children geoDistance(boolean condition, String column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint, Float boost);
GeoPoint geoPoint = new GeoPoint(centralGeoPoint);
return geoDistance(condition, column, distance, distanceUnit, geoPoint, boost);
}
/** /**
* 距离范围查询 以给定圆心和半径范围查询 距离类型为双精度 * 距离范围查询 以给定圆心和半径范围查询 距离类型为双精度
@ -481,8 +473,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(R column, String distance, String centralGeoPoint) { default Children geoDistance(R column, String distance, String centralGeoPoint) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(true, column, distance, centralGeoPoint, DEFAULT_BOOST);
return geoDistance(true, column, distance, geoPoint, DEFAULT_BOOST);
} }
/** /**
@ -495,8 +486,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(boolean condition, R column, String distance, String centralGeoPoint) { default Children geoDistance(boolean condition, R column, String distance, String centralGeoPoint) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(condition, column, distance, centralGeoPoint, DEFAULT_BOOST);
return geoDistance(condition, column, distance, geoPoint, DEFAULT_BOOST);
} }
/** /**
@ -509,8 +499,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(R column, String distance, String centralGeoPoint, Float boost) { default Children geoDistance(R column, String distance, String centralGeoPoint, Float boost) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(true, column, distance, centralGeoPoint, boost);
return geoDistance(true, column, distance, geoPoint, boost);
} }
/** /**
@ -524,8 +513,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(boolean condition, R column, String distance, String centralGeoPoint, Float boost) { default Children geoDistance(boolean condition, R column, String distance, String centralGeoPoint, Float boost) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(condition, FieldUtils.getFieldName(column), distance, centralGeoPoint, boost);
return geoDistance(condition, column, distance, geoPoint, boost);
} }
/** /**
@ -575,8 +563,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(String column, String distance, String centralGeoPoint) { default Children geoDistance(String column, String distance, String centralGeoPoint) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(true, column, distance, centralGeoPoint, DEFAULT_BOOST);
return geoDistance(true, column, distance, geoPoint, DEFAULT_BOOST);
} }
/** /**
@ -589,8 +576,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(boolean condition, String column, String distance, String centralGeoPoint) { default Children geoDistance(boolean condition, String column, String distance, String centralGeoPoint) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(condition, column, distance, centralGeoPoint, DEFAULT_BOOST);
return geoDistance(condition, column, distance, geoPoint, DEFAULT_BOOST);
} }
/** /**
@ -603,8 +589,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(String column, String distance, String centralGeoPoint, Float boost) { default Children geoDistance(String column, String distance, String centralGeoPoint, Float boost) {
GeoPoint geoPoint = new GeoPoint(centralGeoPoint); return geoDistance(true, column, distance, centralGeoPoint, boost);
return geoDistance(true, column, distance, geoPoint, boost);
} }
/** /**
@ -617,10 +602,7 @@ public interface Geo<Children, R> extends Serializable {
* @param boost 权重值 * @param boost 权重值
* @return wrapper * @return wrapper
*/ */
default Children geoDistance(boolean condition, String column, String distance, String centralGeoPoint, Float boost) { Children geoDistance(boolean condition, String column, String distance, String centralGeoPoint, Float boost);
GeoPoint geoPoint = new GeoPoint(centralGeoPoint);
return geoDistance(condition, column, distance, geoPoint, boost);
}
/** /**
* 距离范围查询 以给定圆心和半径范围查询 距离类型为字符串 * 距离范围查询 以给定圆心和半径范围查询 距离类型为字符串
@ -691,11 +673,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoPolygonStr(R column, List<String> strPoints) { default Children geoPolygonStr(R column, List<String> strPoints) {
if (CollectionUtils.isEmpty(strPoints)) { return geoPolygonStr(true, column, strPoints);
throw ExceptionUtils.eee("polygon point list must not be empty");
}
List<GeoPoint> geoPoints = strPoints.stream().map(GeoPoint::new).collect(Collectors.toList());
return geoPolygon(true, column, geoPoints, DEFAULT_BOOST);
} }
/** /**
@ -707,11 +685,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoPolygonStr(boolean condition, R column, List<String> strPoints) { default Children geoPolygonStr(boolean condition, R column, List<String> strPoints) {
if (CollectionUtils.isEmpty(strPoints)) { return geoPolygonStr(condition, FieldUtils.getFieldName(column), strPoints);
throw ExceptionUtils.eee("polygon point list must not be empty");
}
List<GeoPoint> geoPoints = strPoints.stream().map(GeoPoint::new).collect(Collectors.toList());
return geoPolygon(condition, column, geoPoints, DEFAULT_BOOST);
} }
/** /**
@ -723,11 +697,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoPolygonStr(R column, List<String> strPoints, Float boost) { default Children geoPolygonStr(R column, List<String> strPoints, Float boost) {
if (CollectionUtils.isEmpty(strPoints)) { return geoPolygonStr(FieldUtils.getFieldName(column), strPoints, boost);
throw ExceptionUtils.eee("polygon point list must not be empty");
}
List<GeoPoint> geoPoints = strPoints.stream().map(GeoPoint::new).collect(Collectors.toList());
return geoPolygon(true, column, geoPoints, boost);
} }
/** /**
@ -773,11 +743,7 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoPolygonStr(String column, List<String> strPoints) { default Children geoPolygonStr(String column, List<String> strPoints) {
if (CollectionUtils.isEmpty(strPoints)) { return geoPolygonStr(true, column, strPoints);
throw ExceptionUtils.eee("polygon point list must not be empty");
}
List<GeoPoint> geoPoints = strPoints.stream().map(GeoPoint::new).collect(Collectors.toList());
return geoPolygon(true, column, geoPoints, DEFAULT_BOOST);
} }
/** /**
@ -789,10 +755,10 @@ public interface Geo<Children, R> extends Serializable {
* @return wrapper * @return wrapper
*/ */
default Children geoPolygonStr(boolean condition, String column, List<String> strPoints) { default Children geoPolygonStr(boolean condition, String column, List<String> strPoints) {
if (CollectionUtils.isEmpty(strPoints)) { List<GeoPoint> geoPoints = Optional.ofNullable(strPoints).orElseGet(ArrayList::new)
throw ExceptionUtils.eee("polygon point list must not be empty"); .stream()
} .map(GeoPoint::new)
List<GeoPoint> geoPoints = strPoints.stream().map(GeoPoint::new).collect(Collectors.toList()); .collect(Collectors.toList());
return geoPolygon(condition, column, geoPoints, DEFAULT_BOOST); return geoPolygon(condition, column, geoPoints, DEFAULT_BOOST);
} }

View File

@ -498,18 +498,36 @@ public abstract class AbstractChainWrapper<T, R, Children extends AbstractChainW
return typedThis; return typedThis;
} }
@Override
public Children geoBoundingBox(boolean condition, String column, String topLeft, String bottomRight, Float boost) {
getWrapper().geoBoundingBox(condition, column, topLeft, bottomRight, boost);
return typedThis;
}
@Override @Override
public Children geoDistance(boolean condition, String column, Double distance, DistanceUnit distanceUnit, GeoPoint centralGeoPoint, Float boost) { public Children geoDistance(boolean condition, String column, Double distance, DistanceUnit distanceUnit, GeoPoint centralGeoPoint, Float boost) {
getWrapper().geoDistance(condition, column, distance, distanceUnit, centralGeoPoint, boost); getWrapper().geoDistance(condition, column, distance, distanceUnit, centralGeoPoint, boost);
return typedThis; return typedThis;
} }
@Override
public Children geoDistance(boolean condition, String column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint, Float boost) {
getWrapper().geoDistance(condition, column, distance, distanceUnit, centralGeoPoint, boost);
return typedThis;
}
@Override @Override
public Children geoDistance(boolean condition, String column, String distance, GeoPoint centralGeoPoint, Float boost) { public Children geoDistance(boolean condition, String column, String distance, GeoPoint centralGeoPoint, Float boost) {
getWrapper().geoDistance(condition, column, distance, centralGeoPoint, boost); getWrapper().geoDistance(condition, column, distance, centralGeoPoint, boost);
return typedThis; return typedThis;
} }
@Override
public Children geoDistance(boolean condition, String column, String distance, String centralGeoPoint, Float boost) {
getWrapper().geoDistance(condition, column, distance, centralGeoPoint, boost);
return typedThis;
}
@Override @Override
public Children geoPolygon(boolean condition, String column, List<GeoPoint> geoPoints, Float boost) { public Children geoPolygon(boolean condition, String column, List<GeoPoint> geoPoints, Float boost) {
getWrapper().geoPolygon(condition, column, geoPoints, boost); getWrapper().geoPolygon(condition, column, geoPoints, boost);

View File

@ -200,7 +200,9 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
@Override @Override
public Children parentId(boolean condition, Object parentId, String type, Float boost) { public Children parentId(boolean condition, Object parentId, String type, Float boost) {
if (condition) {
Assert.notNull(parentId, "parentId could not be null"); Assert.notNull(parentId, "parentId could not be null");
}
return addParam(condition, PARENT_ID, type, parentId, boost); return addParam(condition, PARENT_ID, type, parentId, boost);
} }
@ -232,8 +234,8 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
@Override @Override
public Children prefixQuery(boolean condition, String column, String prefix, Float boost) { public Children prefixQuery(boolean condition, String column, String prefix, Float boost) {
if (StringUtils.isBlank(prefix)) { if (condition) {
throw ExceptionUtils.eee("prefix can't be blank"); Assert.notBlank(prefix, "prefix can't be blank");
} }
return addParam(condition, PREFIX, column, prefix, boost); return addParam(condition, PREFIX, column, prefix, boost);
} }
@ -301,45 +303,84 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
return addParam(condition, EXISTS, column, null, boost); return addParam(condition, EXISTS, column, null, boost);
} }
@Override
public Children geoBoundingBox(boolean condition, String column, String topLeft, String bottomRight, Float boost) {
if (condition) {
Assert.notBlank(topLeft, "TopLeft must not be null in geoBoundingBox query");
Assert.notBlank(bottomRight, "BottomRight must not be null in geoBoundingBox query");
return geoBoundingBox(true, column, new GeoPoint(topLeft), new GeoPoint(bottomRight), boost);
}
return typedThis;
}
@Override @Override
public Children geoBoundingBox(boolean condition, String column, GeoPoint topLeft, GeoPoint bottomRight, Float boost) { public Children geoBoundingBox(boolean condition, String column, GeoPoint topLeft, GeoPoint bottomRight, Float boost) {
if (condition) {
Assert.notNull(topLeft, "TopLeft point must not be null in geoBoundingBox query"); Assert.notNull(topLeft, "TopLeft point must not be null in geoBoundingBox query");
Assert.notNull(bottomRight, "BottomRight point must not be null in geoBoundingBox query"); Assert.notNull(bottomRight, "BottomRight point must not be null in geoBoundingBox query");
}
return addParam(condition, GEO_BOUNDING_BOX, column, null, topLeft, bottomRight, boost); return addParam(condition, GEO_BOUNDING_BOX, column, null, topLeft, bottomRight, boost);
} }
@Override @Override
public Children geoDistance(boolean condition, String column, Double distance, DistanceUnit distanceUnit, GeoPoint centralGeoPoint, Float boost) { public Children geoDistance(boolean condition, String column, Double distance, DistanceUnit distanceUnit, GeoPoint centralGeoPoint, Float boost) {
if (condition) {
Assert.notNull(distance, "Distance must not be null in geoDistance query"); Assert.notNull(distance, "Distance must not be null in geoDistance query");
Assert.notNull(distanceUnit, "Distance unit must not be null in geoDistance query"); Assert.notNull(distanceUnit, "Distance unit must not be null in geoDistance query");
Assert.notNull(centralGeoPoint, "CentralGeoPoint must not be null in geoDistance query"); Assert.notNull(centralGeoPoint, "CentralGeoPoint must not be null in geoDistance query");
}
return addParam(condition, GEO_DISTANCE, column, distance, distanceUnit, centralGeoPoint, boost); return addParam(condition, GEO_DISTANCE, column, distance, distanceUnit, centralGeoPoint, boost);
} }
@Override
public Children geoDistance(boolean condition, String column, Double distance, DistanceUnit distanceUnit, String centralGeoPoint, Float boost) {
if (condition) {
Assert.notBlank(centralGeoPoint, "centralGeoPoint must not be null in geoDistance query");
return geoDistance(true, column, distance, distanceUnit, new GeoPoint(centralGeoPoint), boost);
}
return typedThis;
}
@Override @Override
public Children geoDistance(boolean condition, String column, String distance, GeoPoint centralGeoPoint, Float boost) { public Children geoDistance(boolean condition, String column, String distance, GeoPoint centralGeoPoint, Float boost) {
Assert.notNull(distance, "Distance must not be null in geoDistance query"); if (condition) {
Assert.notBlank(distance, "Distance must not be null in geoDistance query");
Assert.notNull(centralGeoPoint, "CentralGeoPoint must not be null in geoDistance query"); Assert.notNull(centralGeoPoint, "CentralGeoPoint must not be null in geoDistance query");
}
return addParam(condition, GEO_DISTANCE, column, distance, null, centralGeoPoint, boost); return addParam(condition, GEO_DISTANCE, column, distance, null, centralGeoPoint, boost);
} }
@Override
public Children geoDistance(boolean condition, String column, String distance, String centralGeoPoint, Float boost) {
if (condition) {
Assert.notBlank(centralGeoPoint, "centralGeoPoint must not be null in geoDistance query");
return geoDistance(true, column, distance, new GeoPoint(centralGeoPoint), boost);
}
return typedThis;
}
@Override @Override
public Children geoPolygon(boolean condition, String column, List<GeoPoint> geoPoints, Float boost) { public Children geoPolygon(boolean condition, String column, List<GeoPoint> geoPoints, Float boost) {
if (condition) {
Assert.notEmpty(geoPoints, "GeoPoints must not be null in geoPolygon query"); Assert.notEmpty(geoPoints, "GeoPoints must not be null in geoPolygon query");
}
return addParam(condition, GEO_POLYGON, column, geoPoints, boost); return addParam(condition, GEO_POLYGON, column, geoPoints, boost);
} }
@Override @Override
public Children geoShape(boolean condition, String column, String indexedShapeId, Float boost) { public Children geoShape(boolean condition, String column, String indexedShapeId, Float boost) {
if (condition) {
Assert.notNull(indexedShapeId, "IndexedShapeId must not be null in geoShape query"); Assert.notNull(indexedShapeId, "IndexedShapeId must not be null in geoShape query");
}
return addParam(condition, GEO_SHAPE_ID, column, indexedShapeId, boost); return addParam(condition, GEO_SHAPE_ID, column, indexedShapeId, boost);
} }
@Override @Override
public Children geoShape(boolean condition, String column, Geometry geometry, ShapeRelation shapeRelation, Float boost) { public Children geoShape(boolean condition, String column, Geometry geometry, ShapeRelation shapeRelation, Float boost) {
if (condition) {
Assert.notNull(geometry, "Geometry must not be null in geoShape query"); Assert.notNull(geometry, "Geometry must not be null in geoShape query");
Assert.notNull(geometry, "ShapeRelation must not be null in geoShape query"); Assert.notNull(geometry, "ShapeRelation must not be null in geoShape query");
}
return addParam(condition, GEO_SHAPE, column, geometry, shapeRelation, null, boost); return addParam(condition, GEO_SHAPE, column, geometry, shapeRelation, null, boost);
} }

View File

@ -118,7 +118,7 @@ public class EntityInfoHelper {
} }
boolean camelCase = globalConfig.getDbConfig().isMapUnderscoreToCamelCase(); boolean camelCase = globalConfig.getDbConfig().isMapUnderscoreToCamelCase();
String joinFieldName = camelToUnderline(JoinField.class.getSimpleName(), camelCase); String joinFieldName = camelToUnderline(JoinField.class.getSimpleName(), camelCase);
entityInfo.setJoinFieldName(joinFieldName); entityInfo.setJoinFieldName(StringUtils.isBlank(join.joinField()) ? joinFieldName : join.joinField());
String joinAlias = StringUtils.isBlank(join.rootAlias()) ? clazz.getSimpleName() : join.rootAlias(); String joinAlias = StringUtils.isBlank(join.rootAlias()) ? clazz.getSimpleName() : join.rootAlias();
String underlineJoinAlias = camelToUnderline(joinAlias, camelCase); String underlineJoinAlias = camelToUnderline(joinAlias, camelCase);