elasticsearch - NEST: How to handle array fields which contains a single value (Newtonsoft Json Serialization error) -
during evaluation of elasticsearch in combination nest faced new problem. problem regarding fields array types plus fact array types automatically supported in es. have field productids can contain 1 or n values. mapping defined following:
[…] "productids" : { "type" : " integer", "store" : "yes" }, […]
if field contains couple of ids query result in es looks this:
productids: [ 1, 2 ]
the fact array types automatically, field looks if contains single value:
productids: 1
this circumstances leads following problem: have nest-query mapped class. in class attribute productids defined list<int>
(i tried integer array). works fine long there more single value. if field contains single value in es it’s saved primitive data type. leads error in newtonsoft.json:
connection error. @ newtonsoft.json.serialization.jsonserializerinternalreader.ensuretype(jsonreader reader, object value, cultureinfo culture, jsoncontract contract, type targettype)
at newtonsoft.json.serialization.jsonserializerinternalreader.createvalueinternal(jsonreader reader, type objecttype, jsoncontract contract, jsonproperty member, jsoncontainercontract containercontract, jsonproperty containermember, object existingvalue)
at newtonsoft.json.serialization.jsonserializerinternalreader.setpropertyvalue(jsonproperty property, jsonconverter propertyconverter, jsoncontainercontract containercontract, jsonproperty containerproperty, jsonreader reader, object target)
so suggestions how solve problem? tia
you not first run solution has been provided here: https://github.com/mpdreamz/nest/issues/227#issuecomment-16550076
support out of box in nest planned too.
Comments
Post a Comment