![](/img/trans.png)
[英]How to provide Field type for HashMap of temporal accessors in Spring Data Elasticsearch
[英]Spring data with Elasticsearch 6.4.2 is not working for Java hashmap properties
@Document(createIndex = true,indexName =“相鄰關系”,類型=“相鄰關系”)公共類djacencyDoc {
@Field(type = FieldType.Object)
private Agent agent1 = null;
}
類代理{prop6:480 prop7:類FAttributes7 {attr1Name:[類FAttributes {dscp:12 txInterval:100 padding:425},類FAttributes {dscp:14 txInterval:100 padding:425}]} listIps:類RProperties {attProperties: {PRASANTA3 = class AttProperty {IP:192.168.57.39代理:PRASANTA1 dstId:PRASANTA2}}} iIp:192.168.57.53 ip1:255.255.255.78 ip4:192.168.57.187 testId:空klan:0優先級:0 ID:p1} ntinu空voip:空netqr:空}
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) .
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.