mirror of
https://gitee.com/dromara/easy-es.git
synced 2025-12-06 17:18:57 +08:00
feat: jdk8 es-java7.17.28
This commit is contained in:
parent
79886798b2
commit
7d8e879b4b
@ -14,8 +14,8 @@
|
||||
<artifactId>easy-es-annotation</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
<artifactId>easy-es-boot-starter</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
<artifactId>easy-es-common</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -49,18 +49,4 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version> <!-- 或者更高版本 -->
|
||||
<configuration>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -30,8 +30,8 @@ public class BaseJoin {
|
||||
* @param parentId 父id
|
||||
*/
|
||||
public void addJoinField(String fieldName, String name, String parentId) {
|
||||
joinField = new HashMap<>() {{
|
||||
put(fieldName, new HashMap<>() {{
|
||||
joinField = new HashMap<String, Map<String, String>>() {{
|
||||
put(fieldName, new HashMap<String, String>() {{
|
||||
put("name", name);
|
||||
if (parentId != null) {
|
||||
put("parent", parentId);
|
||||
|
||||
@ -22,7 +22,8 @@ public class JacksonCustomAnnotationIntrospector extends JacksonAnnotationIntros
|
||||
* 获取序列化和反序列化时的名称
|
||||
*/
|
||||
private static PropertyName getPropertyName(Annotated m) {
|
||||
if (m instanceof AnnotatedField f) {
|
||||
if (m instanceof AnnotatedField) {
|
||||
AnnotatedField f = (AnnotatedField) m;
|
||||
JacksonCustomConfig config = JacksonCustomConfig.jacksonConfigMap.get(f.getDeclaringClass());
|
||||
if (config != null) {
|
||||
String jsonName = config.javaJsonFieldNameMap.get(f.getName());
|
||||
@ -58,7 +59,8 @@ public class JacksonCustomAnnotationIntrospector extends JacksonAnnotationIntros
|
||||
*/
|
||||
@Override
|
||||
public JsonIncludeProperties.Value findPropertyInclusionByName(MapperConfig<?> c, Annotated a) {
|
||||
if (a instanceof AnnotatedClass f) {
|
||||
if (a instanceof AnnotatedClass) {
|
||||
AnnotatedClass f = (AnnotatedClass) a;
|
||||
JacksonCustomConfig config = JacksonCustomConfig.jacksonConfigMap.get(f.getAnnotated());
|
||||
if (config != null) {
|
||||
return config.allJsonField;
|
||||
@ -73,7 +75,8 @@ public class JacksonCustomAnnotationIntrospector extends JacksonAnnotationIntros
|
||||
*/
|
||||
@Override
|
||||
public JsonFormat.Value findFormat(Annotated a) {
|
||||
if (a instanceof AnnotatedMethod f) {
|
||||
if (a instanceof AnnotatedMethod) {
|
||||
AnnotatedMethod f = (AnnotatedMethod) a;
|
||||
JacksonCustomConfig config = JacksonCustomConfig.jacksonConfigMap.get(f.getDeclaringClass());
|
||||
if (config != null) {
|
||||
JsonFormat.Value value = config.formatMap.get(f.getName());
|
||||
@ -91,7 +94,8 @@ public class JacksonCustomAnnotationIntrospector extends JacksonAnnotationIntros
|
||||
*/
|
||||
@Override
|
||||
public JsonInclude.Value findPropertyInclusion(Annotated a) {
|
||||
if (a instanceof AnnotatedMember f) {
|
||||
if (a instanceof AnnotatedMember) {
|
||||
AnnotatedMember f = (AnnotatedMember) a;
|
||||
JacksonCustomConfig config = JacksonCustomConfig.jacksonConfigMap.get(f.getDeclaringClass());
|
||||
if (config != null) {
|
||||
JsonInclude.Value value = config.includeMap.get(f.getName());
|
||||
|
||||
@ -14,8 +14,8 @@
|
||||
<artifactId>easy-es-core</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@ -21,7 +21,6 @@ import co.elastic.clients.elasticsearch.indices.PutMappingRequest;
|
||||
import co.elastic.clients.elasticsearch.indices.RefreshRequest;
|
||||
import co.elastic.clients.elasticsearch.indices.RefreshResponse;
|
||||
import co.elastic.clients.elasticsearch.sql.QueryResponse;
|
||||
import co.elastic.clients.elasticsearch.sql.query.SqlFormat;
|
||||
import co.elastic.clients.json.JsonData;
|
||||
import co.elastic.clients.json.JsonpUtils;
|
||||
import co.elastic.clients.transport.TransportOptions;
|
||||
@ -166,7 +165,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
@SneakyThrows
|
||||
public String executeSQL(String sql) {
|
||||
PrintUtils.printSql(sql);
|
||||
QueryResponse response = client.sql().query(x -> x.query(sql).format(SqlFormat.Json));
|
||||
QueryResponse response = client.sql().query(x -> x.query(sql).format("json"));
|
||||
return JsonpUtils.toString(response, new StringBuilder()).toString();
|
||||
}
|
||||
|
||||
@ -216,8 +215,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
.orElse(WrapperProcessor.buildSearchBuilder(wrapper, entityClass))
|
||||
.index(WrapperProcessor.getIndexName(entityClass, wrapper.indexNames))
|
||||
.routing(wrapper.routing)
|
||||
.preference(wrapper.preference)
|
||||
;
|
||||
.preference(wrapper.preference);
|
||||
return builder.build().toString();
|
||||
} catch (Exception e) {
|
||||
throw ExceptionUtils.eee("get search source exception", e);
|
||||
@ -585,7 +583,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
if (CollectionUtils.isEmpty(searchHits)) {
|
||||
return null;
|
||||
}
|
||||
return parseOne(searchHits.getFirst(), wrapper);
|
||||
return parseOne(searchHits.get(0), wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -993,7 +991,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
SearchRequest searchRequest = new SearchRequest.Builder()
|
||||
.index(indexName)
|
||||
.routing(routing)
|
||||
.query(QueryBuilders.ids().values(List.of(id.toString())).build()._toQuery())
|
||||
.query(QueryBuilders.ids().values(id.toString()).build()._toQuery())
|
||||
.build();
|
||||
// 请求es获取数据
|
||||
List<Hit<T>> searchHits = getSearchHits(searchRequest);
|
||||
@ -1002,7 +1000,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
}
|
||||
|
||||
// 解析数据并返回
|
||||
return parseOne(searchHits.getFirst());
|
||||
return parseOne(searchHits.get(0));
|
||||
}
|
||||
|
||||
|
||||
@ -1036,8 +1034,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
.orElse(WrapperProcessor.buildSearchBuilder(wrapper, entityClass))
|
||||
.index(WrapperProcessor.getIndexName(entityClass, wrapper.indexNames))
|
||||
.routing(wrapper.routing)
|
||||
.preference(wrapper.preference)
|
||||
;
|
||||
.preference(wrapper.preference);
|
||||
|
||||
if (needSearchAfter && CollectionUtils.isNotEmpty(searchAfter)) {
|
||||
builder.searchAfter(searchAfter);
|
||||
@ -1271,7 +1268,8 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
}
|
||||
|
||||
// 嵌套对象为容器的情况
|
||||
if (invoke instanceof Collection<?> coll) {
|
||||
if (invoke instanceof Collection<?>) {
|
||||
Collection<?> coll = (Collection<?>) invoke;
|
||||
Iterator<?> iterator = coll.iterator();
|
||||
int i = 0;
|
||||
while (iterator.hasNext()) {
|
||||
@ -1414,9 +1412,10 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
|
||||
// 针对父子类型-追加joinField信息
|
||||
if (StringUtils.isNotBlank(entityInfo.getJoinAlias())) {
|
||||
if (!(entity instanceof BaseJoin b)) {
|
||||
if (!(entity instanceof BaseJoin)) {
|
||||
throw ExceptionUtils.eee("实体类" + entityClass.getName() + "必须继承BaseJoin实现Join功能");
|
||||
}
|
||||
BaseJoin b = (BaseJoin) entity;
|
||||
b.addJoinField(entityInfo.getJoinFieldName(), entityInfo.getJoinAlias(), entityInfo.isChild() ? parentId : null);
|
||||
}
|
||||
|
||||
@ -1619,7 +1618,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
if (Objects.nonNull(searchResponse)
|
||||
&& searchResponse.shards().failures() != null
|
||||
&& searchResponse.shards().failures().size() > ZERO) {
|
||||
String errorMsg = searchResponse.shards().failures().getFirst().toString();
|
||||
String errorMsg = searchResponse.shards().failures().get(0).toString();
|
||||
throw ExceptionUtils.eee("search response failed ,failedShards: " + errorMsg);
|
||||
}
|
||||
}
|
||||
@ -1632,11 +1631,14 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
private Refresh getRefreshPolicy() {
|
||||
// 防止傻狍子用户在全局中把刷新策略修改为GLOBAL
|
||||
final RefreshPolicy refreshPolicy = Optional.ofNullable(EntityInfoHelper.getEntityInfo(entityClass).getRefreshPolicy()).orElse(RefreshPolicy.NONE);
|
||||
return switch (refreshPolicy) {
|
||||
case RefreshPolicy.IMMEDIATE -> Refresh.True;
|
||||
case RefreshPolicy.WAIT_UNTIL -> Refresh.WaitFor;
|
||||
default -> Refresh.False;
|
||||
};
|
||||
switch (refreshPolicy) {
|
||||
case IMMEDIATE:
|
||||
return Refresh.True;
|
||||
case WAIT_UNTIL:
|
||||
return Refresh.WaitFor;
|
||||
default:
|
||||
return Refresh.False;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -141,61 +141,57 @@ public class WrapperProcessor {
|
||||
break;
|
||||
case GT:
|
||||
realField = getRealFieldAndSuffix(param.getColumn(), fieldTypeMap, mappingColumnMap, entityInfo);
|
||||
query = Query.of(q -> q.range(p ->
|
||||
p.untyped(v -> {
|
||||
v.field(realField).gt(JsonData.of(param.getVal())).boost(param.getBoost());
|
||||
Optional.ofNullable(param.getExt1()).ifPresent(ext1 -> v.timeZone(((ZoneId) ext1).getId()));
|
||||
Optional.ofNullable(param.getExt2()).ifPresent(ext2 -> v.format(ext2.toString()));
|
||||
return v;
|
||||
})
|
||||
query = Query.of(q -> q.range(p -> p
|
||||
.field(realField)
|
||||
.gt(JsonData.of(param.getVal()))
|
||||
.timeZone(param.getExt1() == null ? null : ((ZoneId) param.getExt1()).getId())
|
||||
.format((String)param.getExt2())
|
||||
.boost(param.getBoost())
|
||||
));
|
||||
setBool(bool, query, param.getPrevQueryType());
|
||||
break;
|
||||
case GE:
|
||||
realField = getRealFieldAndSuffix(param.getColumn(), fieldTypeMap, mappingColumnMap, entityInfo);
|
||||
query = Query.of(q -> q.range(p ->
|
||||
p.untyped(v -> {
|
||||
v.field(realField).gte(JsonData.of(param.getVal())).boost(param.getBoost());
|
||||
Optional.ofNullable(param.getExt1()).ifPresent(ext1 -> v.timeZone(((ZoneId) ext1).getId()));
|
||||
Optional.ofNullable(param.getExt2()).ifPresent(ext2 -> v.format(ext2.toString()));
|
||||
return v;
|
||||
})
|
||||
query = Query.of(q -> q.range(p -> p
|
||||
.field(realField)
|
||||
.gte(JsonData.of(param.getVal()))
|
||||
.timeZone(param.getExt1() == null ? null : ((ZoneId) param.getExt1()).getId())
|
||||
.format((String)param.getExt2())
|
||||
.boost(param.getBoost())
|
||||
));
|
||||
setBool(bool, query, param.getPrevQueryType());
|
||||
break;
|
||||
case LT:
|
||||
realField = getRealFieldAndSuffix(param.getColumn(), fieldTypeMap, mappingColumnMap, entityInfo);
|
||||
query = Query.of(q -> q.range(p ->
|
||||
p.untyped(v -> {
|
||||
v.field(realField).lt(JsonData.of(param.getVal())).boost(param.getBoost());
|
||||
Optional.ofNullable(param.getExt1()).ifPresent(ext1 -> v.timeZone(((ZoneId) ext1).getId()));
|
||||
Optional.ofNullable(param.getExt2()).ifPresent(ext2 -> v.format(ext2.toString()));
|
||||
return v;
|
||||
})
|
||||
query = Query.of(q -> q.range(p -> p
|
||||
.field(realField)
|
||||
.lt(JsonData.of(param.getVal()))
|
||||
.timeZone(param.getExt1() == null ? null : ((ZoneId) param.getExt1()).getId())
|
||||
.format((String)param.getExt2())
|
||||
.boost(param.getBoost())
|
||||
));
|
||||
setBool(bool, query, param.getPrevQueryType());
|
||||
break;
|
||||
case LE:
|
||||
realField = getRealFieldAndSuffix(param.getColumn(), fieldTypeMap, mappingColumnMap, entityInfo);
|
||||
query = Query.of(q -> q.range(p ->
|
||||
p.untyped(v -> {
|
||||
v.field(realField).lte(JsonData.of(param.getVal())).boost(param.getBoost());
|
||||
Optional.ofNullable(param.getExt1()).ifPresent(ext1 -> v.timeZone(((ZoneId) ext1).getId()));
|
||||
Optional.ofNullable(param.getExt2()).ifPresent(ext2 -> v.format(ext2.toString()));
|
||||
return v;
|
||||
})
|
||||
query = Query.of(q -> q.range(p -> p
|
||||
.field(realField)
|
||||
.lte(JsonData.of(param.getVal()))
|
||||
.timeZone(param.getExt1() == null ? null : ((ZoneId) param.getExt1()).getId())
|
||||
.format((String)param.getExt2())
|
||||
.boost(param.getBoost())
|
||||
));
|
||||
setBool(bool, query, param.getPrevQueryType());
|
||||
break;
|
||||
case BETWEEN:
|
||||
realField = getRealFieldAndSuffix(param.getColumn(), fieldTypeMap, mappingColumnMap, entityInfo);
|
||||
query = Query.of(q -> q.range(p ->
|
||||
p.untyped(v -> {
|
||||
v.field(realField).gte(JsonData.of(param.getExt1())).lte(JsonData.of(param.getExt2())).boost(param.getBoost());
|
||||
Optional.ofNullable(param.getExt3()).ifPresent(ex -> v.timeZone(((ZoneId) ex).getId()));
|
||||
Optional.ofNullable(param.getExt4()).ifPresent(ex -> v.format(ex.toString()));
|
||||
return v;
|
||||
})
|
||||
query = Query.of(q -> q.range(p -> p
|
||||
.field(realField)
|
||||
.gte(JsonData.of(param.getExt1()))
|
||||
.lte(JsonData.of(param.getExt2()))
|
||||
.timeZone(param.getExt3() == null ? null : ((ZoneId) param.getExt3()).getId())
|
||||
.format((String)param.getExt4())
|
||||
.boost(param.getBoost())
|
||||
));
|
||||
setBool(bool, query, param.getPrevQueryType());
|
||||
break;
|
||||
@ -330,17 +326,24 @@ public class WrapperProcessor {
|
||||
* @return FieldValue
|
||||
*/
|
||||
public static FieldValue fieldValue(Object val) {
|
||||
return switch (val) {
|
||||
case null -> FieldValue.NULL;
|
||||
case FieldValue fieldValue -> fieldValue;
|
||||
case Long l -> FieldValue.of((long) val);
|
||||
case Integer i -> FieldValue.of((int) val);
|
||||
case Double v -> FieldValue.of((double) val);
|
||||
case Boolean b -> FieldValue.of((boolean) val);
|
||||
case String s -> FieldValue.of(s);
|
||||
default -> FieldValue.of(val);
|
||||
};
|
||||
if (val == null) {
|
||||
return FieldValue.NULL;
|
||||
}
|
||||
|
||||
if (val instanceof FieldValue) {
|
||||
return (FieldValue) val;
|
||||
} else if (val instanceof Long) {
|
||||
return FieldValue.of((long) val);
|
||||
} else if (val instanceof Integer) {
|
||||
return FieldValue.of((int) val);
|
||||
} else if (val instanceof Double) {
|
||||
return FieldValue.of((double) val);
|
||||
} else if (val instanceof Boolean) {
|
||||
return FieldValue.of((boolean) val);
|
||||
} else if (val instanceof String) {
|
||||
return FieldValue.of((String) val);
|
||||
}
|
||||
return FieldValue.of(val);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -584,7 +587,7 @@ public class WrapperProcessor {
|
||||
HighlightField field = HighlightField.of(x -> x
|
||||
.preTags(highLightParam.getPreTag())
|
||||
.postTags(highLightParam.getPostTag())
|
||||
.type(highLightParam.getHighLightType().getValue())
|
||||
.type(a -> a.custom(highLightParam.getHighLightType().getValue()))
|
||||
.requireFieldMatch(highLightParam.getRequireFieldMatch())
|
||||
);
|
||||
highlightBuilder.fields(highlightField, field);
|
||||
@ -643,18 +646,24 @@ public class WrapperProcessor {
|
||||
* @return 排序器
|
||||
*/
|
||||
private static SortOptions getSortBuilder(String realField, BaseSortParam baseSortParam) {
|
||||
return switch (baseSortParam.getOrderTypeEnum()) {
|
||||
case FIELD -> SortOptions.of(x -> x.field(y -> y.field(realField).order(baseSortParam.getSortOrder())));
|
||||
case SCORE -> SortOptions.of(x -> x.score(y -> y.order(baseSortParam.getSortOrder())));
|
||||
case GEO -> SortOptions.of(x -> x.geoDistance(y -> y
|
||||
.field(realField)
|
||||
.location(baseSortParam.getGeoPoints())
|
||||
.order(baseSortParam.getSortOrder())
|
||||
.distanceType(baseSortParam.getGeoDistanceType())
|
||||
.unit(baseSortParam.getUnit())
|
||||
));
|
||||
case CUSTOMIZE -> baseSortParam.getSortBuilder();
|
||||
};
|
||||
switch (baseSortParam.getOrderTypeEnum()) {
|
||||
case FIELD:
|
||||
return SortOptions.of(x -> x.field(y -> y.field(realField).order(baseSortParam.getSortOrder())));
|
||||
case SCORE:
|
||||
return SortOptions.of(x -> x.score(y -> y.order(baseSortParam.getSortOrder())));
|
||||
case GEO:
|
||||
return SortOptions.of(x -> x.geoDistance(y -> y
|
||||
.field(realField)
|
||||
.location(baseSortParam.getGeoPoints())
|
||||
.order(baseSortParam.getSortOrder())
|
||||
.distanceType(baseSortParam.getGeoDistanceType())
|
||||
.unit(baseSortParam.getUnit())
|
||||
));
|
||||
case CUSTOMIZE:
|
||||
return baseSortParam.getSortBuilder();
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -739,17 +748,24 @@ public class WrapperProcessor {
|
||||
List<NamedValue<SortOrder>> bucketOrders
|
||||
) {
|
||||
// 解决同一个字段聚合多次,如min(starNum), max(starNum) 字段名重复问题
|
||||
return switch (aggType) {
|
||||
case AVG -> new Aggregation.Builder().avg(x -> x.field(realField));
|
||||
case MIN -> new Aggregation.Builder().min(x -> x.field(realField));
|
||||
case MAX -> new Aggregation.Builder().max(x -> x.field(realField));
|
||||
case SUM -> new Aggregation.Builder().sum(x -> x.field(realField));
|
||||
case TERMS -> new Aggregation.Builder().terms(x -> {
|
||||
x.field(realField);
|
||||
Optional.ofNullable(size).ifPresent(x::size);
|
||||
Optional.ofNullable(bucketOrders).ifPresent(x::order);
|
||||
return x;
|
||||
});
|
||||
};
|
||||
switch (aggType) {
|
||||
case AVG:
|
||||
return new Aggregation.Builder().avg(x -> x.field(realField));
|
||||
case MIN:
|
||||
return new Aggregation.Builder().min(x -> x.field(realField));
|
||||
case MAX:
|
||||
return new Aggregation.Builder().max(x -> x.field(realField));
|
||||
case SUM:
|
||||
return new Aggregation.Builder().sum(x -> x.field(realField));
|
||||
case TERMS:
|
||||
return new Aggregation.Builder().terms(x -> {
|
||||
x.field(realField);
|
||||
Optional.ofNullable(size).ifPresent(x::size);
|
||||
Optional.ofNullable(bucketOrders).ifPresent(x::order);
|
||||
return x;
|
||||
});
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,12 +85,16 @@ public class GeoUtils {
|
||||
return createFromGeoHash(geohash);
|
||||
} else {
|
||||
Rectangle rectangle = Geohash.toBoundingBox(geohash);
|
||||
return switch (effectivePoint) {
|
||||
case TOP_LEFT -> create(rectangle.getMaxY(), rectangle.getMinX());
|
||||
case TOP_RIGHT -> create(rectangle.getMaxY(), rectangle.getMaxX());
|
||||
case BOTTOM_RIGHT -> create(rectangle.getMinY(), rectangle.getMaxX());
|
||||
default -> throw new IllegalArgumentException("Unsupported effective point " + effectivePoint);
|
||||
};
|
||||
switch (effectivePoint) {
|
||||
case TOP_LEFT:
|
||||
return create(rectangle.getMaxY(), rectangle.getMinX());
|
||||
case TOP_RIGHT:
|
||||
return create(rectangle.getMaxY(), rectangle.getMaxX());
|
||||
case BOTTOM_RIGHT:
|
||||
return create(rectangle.getMinY(), rectangle.getMaxX());
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported effective point " + effectivePoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,8 +132,14 @@ public class GeoUtils {
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
public static Map<String, Object> toMap(Geometry geometry) {
|
||||
String geoJsonName = null;
|
||||
try {
|
||||
geoJsonName = getGeoJsonName(geometry);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Map<String, Object> root = new HashMap<>();
|
||||
root.put("type", getGeoJsonName(geometry));
|
||||
root.put("type", geoJsonName);
|
||||
|
||||
geometry.visit(new GeometryVisitor<Void, RuntimeException>() {
|
||||
@Override
|
||||
@ -267,8 +277,8 @@ public class GeoUtils {
|
||||
* @param geometry geometry
|
||||
* @return String
|
||||
*/
|
||||
public static String getGeoJsonName(Geometry geometry) {
|
||||
return geometry.visit(new GeometryVisitor<>() {
|
||||
public static String getGeoJsonName(Geometry geometry) throws Exception {
|
||||
return geometry.visit(new GeometryVisitor<String, Exception>() {
|
||||
@Override
|
||||
public String visit(Circle circle) {
|
||||
return "Circle";
|
||||
|
||||
@ -134,9 +134,10 @@ public class PrintUtils {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!(body instanceof NdJsonpSerializable nd)) {
|
||||
if (!(body instanceof NdJsonpSerializable)) {
|
||||
return JsonpUtils.toJsonString(body, mapper);
|
||||
}
|
||||
NdJsonpSerializable nd = (NdJsonpSerializable) body;
|
||||
|
||||
StringBuilder bodyStr = new StringBuilder();
|
||||
collectNdJsonLines(bodyStr, nd, mapper);
|
||||
@ -156,7 +157,8 @@ public class PrintUtils {
|
||||
Object item = values.next();
|
||||
if (item == null) {
|
||||
// skip
|
||||
} else if (item instanceof NdJsonpSerializable nd && item != value) { // do not recurse on the item itself
|
||||
} else if (item instanceof NdJsonpSerializable && item != value) {
|
||||
NdJsonpSerializable nd = (NdJsonpSerializable) item; // do not recurse on the item itself
|
||||
collectNdJsonLines(body, nd, mapper);
|
||||
} else {
|
||||
body.append(JsonpUtils.toJsonString(item, mapper)).append("\n");
|
||||
|
||||
@ -14,8 +14,8 @@
|
||||
<artifactId>easy-es-extension</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@ -32,9 +32,8 @@
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<lombok.version>1.18.36</lombok.version>
|
||||
<elasticsearch.java.version>8.17.1</elasticsearch.java.version>
|
||||
<elasticsearch.java.version>7.17.28</elasticsearch.java.version>
|
||||
<jackson.version>2.18.2</jackson.version>
|
||||
<fastjson.version>1.2.83</fastjson.version>
|
||||
<jakarta.json.version>2.1.3</jakarta.json.version>
|
||||
<codec.version>1.13</codec.version>
|
||||
<spring-boot.version>2.7.16</spring-boot.version>
|
||||
@ -99,12 +98,6 @@
|
||||
<version>${elasticsearch.java.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jakarta.json</groupId>
|
||||
<artifactId>jakarta.json-api</artifactId>
|
||||
|
||||
@ -10,8 +10,8 @@
|
||||
<artifactId>easy-es-solon-plugin</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
<artifactId>easy-es-solon-test</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
<artifactId>easy-es-spring-test</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<junit-jupiter-engine.version>5.8.2</junit-jupiter-engine.version>
|
||||
<spring-boot.version>2.7.18</spring-boot.version>
|
||||
</properties>
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
<artifactId>easy-es-spring</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
<artifactId>easy-es-springboot-test</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user