elasticsearch - How to exclude inherited object properties from mappings -
i'm trying setup mapping object looks this:
class testobject { public long testid { get; set; } [elasticproperty(type = fieldtype.object)] public dictionary<long, list<datetime>> items { get; set; } }
i use following mapping code (where client ielasticclient
):
this.client.map<testobject>(m => m.mapfromattributes());
i following mapping result:
{ "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" } } } }
this becomes problem when want search this:
{ "query_string": { "query": "[2015-06-03t00:00:00.000 2015-06-05t23:59:59.999]", "fields": [ "items.*" ] } }
this causes exceptions, guess because of fields in items object not of same type. proper mapping searches of type?
i able fix using following mapping:
this.client.map<testobject>(m => m.mapfromattributes()) .properties(p => p .object<dictionary<long, list<datetime>>>(o => o.name("items")));
Comments
Post a Comment