我正在使用NEST API(v0.12.0.0)与ElasticSearch(v1.0.1)索引进行交互,我刚刚在检索数据时收到了JsonSerializationException。我不确定这是否是NEST问题,或者它只是随机开始发生,我们没有对我们的实施或基础设施做任何重大改变。
我正在尝试使用类型化的搜索<>()检索我的数据ID(存储为Guid),当JSON.NET处理数据时,我收到异常。
client.Search<ESEventItem>(s =>
s.Index("dev-events004")
.Fields(f => f.Id).Size(100000)
.Type("event").MatchAll()).Documents.ToList()
在Sense中手动运行相同的查询不会产生明显的问题:
POST /dev-events004/event/_search
{
"size": 100000,
"query": {
"match_all": {}
},
"fields": [
"id"
]
}
{
"took": 2088,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 19257,
"max_score": 1,
"hits": [
{
"_index": "dev-events004",
"_type": "event",
"_id": "670a1055-cbe3-480e-b807-a2b500f9dfb3",
"_score": 1,
"fields": {
"id": [
"670a1055-cbe3-480e-b807-a2b500f9dfb3"
]
}
},
/* ... additional results ... */
]
}
}
如果我执行原始的无类型查询Fields(new[] { "Id" })
,它不会抛出异常。同样,如果我返回整个ESEventItem对象,而不仅仅是Id字段,它也可以无异常地工作。
致NEST开发人员:此问题被镜像为issue on the github project。
答案 0 :(得分:2)
这是因为elasticsearch 1.0改变了字段的返回方式。升级的NEST 1.0将支持这一点。