我有以下的JSON通过elasticsearch未来:使用C#巢API来获取嵌套的JSON数据不会检索数据
{
"_index": "data-2016-01-14",
"_type": "type-data",
"_id": "AVJBBNG-TE8FYIA1rf1p",
"_score": 1,
"_source": {
"@message": {
"timestamp": 1452789770326461200,
"eventID": 1452789770326461200,
"eventName": "New",
"Price": "38.34",
"Qty": 100,
"statistic_LatencyValue_ns": 1142470,
"statistic_LatencyViolation": false,
"statistic_LossViolation": false
},
"@timestamp": "2016-01-14T16:42:50.326Z",
"@fields": {
"timestamp": "1452789770326"
}
},
"fields": {
"@timestamp": [
1452789770326
]
}
}
我使用谷,试图获得eventName的数据我创建的类和标记属性:
public class ElasticTest
{
[ElasticProperty(Type = FieldType.Nested)]
public string eventName { get; set; }
}
但下面的查询返回0的结果,我究竟做错了什么?
var result = client.Search<CorvilTest>(s => s
.From(0)
.Size(10000)
.Query(x => x
.Term(e => e.eventName,"New"))
);
var r = result.Documents;
映射定义:
{
"data-2016-01-14": {
"mappings": {
"type-data": {
"properties": {
"@fields": {
"properties": {
"timestamp": {
"type": "string"
}
}
},
"@message": {
"properties": {
"OrderQty": {
"type": "long"
},
"Price": {
"type": "string"
},
"eventID": {
"type": "long"
},
"eventName": {
"type": "string"
},
"statistic_LatencyValue_ns": {
"type": "long"
},
"statistic_LatencyViolation": {
"type": "boolean"
},
"statistic_LossViolation": {
"type": "boolean"
},
"timestamp": {
"type": "long"
}
}
},
"@timestamp": {
"type": "date",
"format": "dateOptionalTime"
}
}
}
}
}
}
请分享'型data'映射的定义。 – bittusarkar
我怎样才能得到这个?我不明白你的问题,对不起。 –
执行Sense命令'GET data-2016-01-14/_mapping/type-data'并共享输出。 – bittusarkar