i fetching marketcatalogue data betfair api-ng , want store in elasticsearch (v1.4.4).
the data coming api contains lot of properties , complex types. there complex type named runners contains related data , dictionary<string,string>
. want define such mapping store data in elasticsearch. sample mapping below:
"marketcatalogue" :{ "properties":{ "marketid":{"type":"string", "index": "not_analyzed" }, "marketname":{"type":"string", "analyzer":"keylower" }, "ismarketdatadelayed":{"type","boolean"}, "description":{ "persistenceenabled":{"type","boolean"}, "bspmarket":{"type","boolean"}, "markettime":{"type" : "date","format":"dateoptionaltime"}, "suspendtime":{"type" : "date","format":"dateoptionaltime"}, "settletime":{"type" : "date","format":"dateoptionaltime"}, "bettingtype":{"type":"integer"}, "turninplayenabled":{"type","boolean"}, "markettype":{"type":"string", "analyzer":"keylower" }, "regulator":{"type":"string", "analyzer":"keylower" }, "marketbaserate":{"type":"double"}, "discountallowed":{"type","boolean"}, "wallet":{"type":"string", "analyzer":"keylower"}, "rules":{"type":"string"}, "ruleshasdate":{"type","boolean"}, "clarifications":{"type":"string"} }, "runners":{ "selectionid":{"type":"long"}, "runnername":{"type":"string", "analyzer":"keylower"}, "handicap":{"type":"double"}, "metadata":{ } } } }
}
the medatadata dictionary<string,string>
coming api , can contain data like:
<"trainer_name", "john">, <"wearing", "wearing one">,....
storing data type not big deal problem how define mapping dictionary.
any save lot of time , make me learn mapping creation better way.
thanks in advance.
every single field in elasticsearch can both singular value, or array of values. includes objects:
"metadata" : { "type" : "object", "properties" : { "key" : { "type" : "string", "index" : "not_analyzed" }, "value" : { "type" : "string", "index" : "not_analyzed" } } }
then if json looked this, picked above mapping:
{ ..., "metadata": [ { "key" : "trainer_home", "value" : "john" }, { "key" : "wearing", "value" : "wearing one" } ] }
alternatively, if don't want search data, want accepted index part of _source
, not index individual fields (this reduces size of index if you're not going use metadata search):
{ "metadata" : { "type" : "object", "dynamic" : false } }
this means can never data inside of es, there when query against other fields.
if want search metadata, probably want use "type" : "nested"
rather object (be sure take note @ bottom seriously; nothing free).