1
我試圖建立一個對象,它看起來像這樣的映射排除繼承的對象屬性:如何從映射
class TestObject
{
public long TestID { get; set; }
[ElasticProperty(Type = FieldType.Object)]
public Dictionary<long, List<DateTime>> Items { get; set; }
}
我用下面的映射代碼(其中客戶端是IElasticClient
):
this.Client.Map<TestObject>(m => m.MapFromAttributes());
我碰到下面的映射結果:
{
"mappings": {
"testobject": {
"properties": {
"items": {
"properties": {
"comparer": {
"type": "object"
},
"count": {
"type": "integer"
},
"item": {
"type": "date",
"format": "dateOptionalTime"
},
"keys": {
"properties": {
"count": {
"type": "integer"
}
}
},
"values": {
"properties": {
"count": {
"type": "integer"
}
}
}
}
},
"testID": {
"type": "long"
}
}
}
}
這將成爲一個問題,當我想要做這樣的搜索:
{
"query_string": {
"query": "[2015-06-03T00:00:00.000 TO 2015-06-05T23:59:59.999]",
"fields": [
"items.*"
]
}
}
這導致例外,我猜是因爲在項目的所有字段對象是同一類型的不行。什麼是適當的映射到這種類型的搜索?