我有以下文件:
{
"_index" : "testdb",
"_type" : "artWork",
"_id" : "0",
"_version" : 4,
"found" : true,
"_source":{"uuid":0,
"StatusHistoryList":[
{
"ArtWorkDate":"2015-08-28T15:52:03.030+05:00",
"ArtworkStatus":"ACTIVE"
},
{
"ArtWorkDate":"2015-08-28T15:52:03.030+05:00",
"ArtworkStatus":"INACTIVE"
}
]
}
这是文档的映射:
{
"testdb" : {
"mappings" : {
"artWork" : {
"properties" : {
"StatusHistoryList" : {
"type" : "nested",
"properties" : {
"ArtWorkDate" : {
"type" : "string",
"store" : true
},
"ArtworkStatus" : {
"type" : "string",
"store" : true
}
}
},
"uuid" : {
"type" : "integer",
"store" : true
}
}
}
}
}
}
现在我想访问StatusHistoryList
. 如果我这样做,我会得到空值:
val get = client.prepareGet("testdb", "artWork", Id.toString()).setOperationThreaded(false)
.setFields("uuid",,"StatusHistoryList.ArtworkStatus","StatusHistoryList.ArtWorkDate","_source")
.execute()
.actionGet()
var artworkStatusList= get.getField("StatusHistoryList.ArtworkStatus").getValues.toArray()
var artWorkDateList= get.getField("StatusHistoryList.ArtWorkDate").getValues.toArray()
然后我从代码中得到空值,但我的文档包含这些值然后我发现了这个问题 ,所以之后我尝试这样做
var smap = get.getSource.get("StatusHistoryList").asInstanceOf[Map[String,Object]]
但随后 aClassCastException
被抛出
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Map
请帮助我如何获得StatusHistoryList
's ArtworkStatus
和ArtWorkDate
值的值,请指导我,我将非常感谢你。