gpt4 book ai didi

java - Elasticsearch 6.4.2 的 Spring 数据不适用于 Java hashmap 属性

转载 作者:行者123 更新时间:2023-12-02 03:27:14 24 4
gpt4 key购买 nike

使用@Document将java对象映射到elasticSearch文档

@Document(createIndex = true, indexName = "djacency", type = "djacency") 公共(public)类 djacencyDoc {

@Field(type = FieldType.Object)
private Agent agent1 = null;
}

保存前设置的类值:

类代理{ Prop 6:480 prop7: 类 FAttributes7{ attr1Name : [类 FAttributes { dscp:12 发送间隔:100 填充:425 }, 类 FAttributes { dscp:14 发送间隔:100 填充:425 }] } listIps: 类 RProperties { attProperties:{PRASANTA3 =类AttProperty { ip: 192.168.57.39 代理: 普拉桑塔1 dstId:PRASANTA2 }} } IP: 192.168.57.53 IP1: 255.255.255.78 IP4:192.168.57.1​​87 测试ID:空 三K党: 0 优先级:0 编号:p1 } 连续性:空 语音:空 网络qr:空 }

 Here "listIps" value is "RProperties" which is a Java Hashmap ,Before save it has some value but While saving into elasticsearch RProperties value is saved as null.

保存后获取的类值:

Agent: class Agent2 {
prop1: true
prop2: 50000
prop3: 50000
prop4: 300
prop5: null
prop6: 480
prop7: class Agent3 {
attr1Name : [class FAttributes {
dscp: 12
txInterval: 100
padding: 425
}, class FAttributes {
dscp: 14
txInterval: 100
padding: 425
}]
}
listIps: class RProperties {
RProperties: null
}
iIp: 192.168.57.53
sunet: 255.255.255.78
gway: 192.168.57.187
testId: null
van: 0
vriority: 0
phyId: p1
}
sContinuity: null
ip: null
nQuality: null
}

Why for hashmap properties "RProperties" elasticseach saves null ? The above document is saving correctly when i am using postman or curl, But from my SpringBoot Application using Spring DATA it is not working .

最佳答案

listIps:class RProperties{  
attProperties:{
PRASANTA3=class AttProperty{
Ip:192.168.57.39;
Agent:PRASANTA1 ;
dstId:PRASANTA2
}
}
}

The above code should be like below format,

listIps:class RProperties extends HashMap<String,AttProperty>{
"PRASANTA3"=class AttProperty{
Ip:192.168.57.39;
Agent:PRASANTA1 ;
dstId:PRASANTA2
}
}


Here RProperties class should extends from Hashmap , instead of RProperties contains one more class (AttProperties) which again contains the hashmap properties.

Here RProperties is a HashMap which contains key("PRASANTA3"),value(AttProperty class values) .

关于java - Elasticsearch 6.4.2 的 Spring 数据不适用于 Java hashmap 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56902894/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com