import com.fasterxml.jackson.databind.JsonNode;
public static class GeoShape {
String type;
JsonNode coordinates;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public JsonNode getCoordinates() {
return coordinates;
}
public void setCoordinates(JsonNode coordinates) {
this.coordinates = coordinates;
}
}
我有弹性搜索的地理形状映射,这适用于保存/检索的 spring 数据 .
0
@ m1416的答案是正确的 - 但只有在你使用ES时才有效 .
您会发现,如果您尝试将JPA / Hibernate与ES一起使用,则不会转换为't work. Hibernate will complain that it can't . 如果您为json节点搜索转换器类,则在提交后回滚步骤中'll find several classes that don'工作或产生隐藏的序列化错误 .
2 回答
Dunno如果这有帮助,但我所做的就是 Build 一个 class
我有弹性搜索的地理形状映射,这适用于保存/检索的 spring 数据 .
@ m1416的答案是正确的 - 但只有在你使用ES时才有效 .
您会发现,如果您尝试将JPA / Hibernate与ES一起使用,则不会转换为't work. Hibernate will complain that it can't . 如果您为json节点搜索转换器类,则在提交后回滚步骤中'll find several classes that don'工作或产生隐藏的序列化错误 .
我一直在寻找很多时间来找到如何使这种方式工作,让您通过ES进行地理搜索,而不会出现这些序列化错误 .
这是一个有效的JsonNodeConverter:
要使用它,请在实体的JsonNode属性上执行以下注释: