如何从映射中排除继承的对象属性

How to exclude inherited object properties from mappings

我正在尝试为如下所示的对象设置映射:

class TestObject
{
    public long TestID { get; set; }

    [ElasticProperty(Type = FieldType.Object)]
    public Dictionary<long, List<DateTime>> Items { get; set; }
}

我使用以下映射代码(其中 Client 为 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.*"
                ]
              }
            }

这会导致异常,我猜这是因为 items 对象中的所有字段都不是同一类型。这种类型的搜索的正确映射是什么?

我能够使用以下映射解决此问题:

this.Client.Map<TestObject>(m => m.MapFromAttributes())
    .Properties(p => p
        .Object<Dictionary<long, List<DateTime>>>(o => o.Name("items")));