c# - Nest.Search How do I get the field value for a short using Hits.Fields.FieldValue -
c# - Nest.Search<T> How do I get the field value for a short using Hits.Fields.FieldValue<object,short> -
i'm attempting homecoming required fields during utilize of search<t>
returns isearchresponse<t>
i specifying fields bring e.g fields("abspath","urllen") , these indeed brought in responses' hits object.
note:page dto , contains public properties abspath (string) & urllen(short).
the documented method field contains string works fine:
var abspath = hits.fields.fieldvalue<page, string>(f => f.abspath)[0]
but trying short or int or long fails null exception (since urllen null):
var length= hits.fields.fieldvalue<page, short>(f => f.urllen)[0]
so missing here?
it fails because during look resolution (f=>f.urllen) resolve(...) method camel cases response fails.
sure plenty downloading source code github , adding in unit test confirms this. changing es object field name 'urllen' fixes problem. problem code area is
public string resolve(memberinfo info) { if (info == null) homecoming null; var name = info.name; **var resolvedname = name.tocamelcase();** var att = elasticattributes.property(info); if (att != null && !att.name.isnullorempty()) resolvedname = att.name; homecoming resolvedname; }
this design - see http://elasticsearch-users.115913.n3.nabble.com/lowercase-property-names-from-net-using-nest-td4039978.html quick fix. see http://nest.azurewebsites.net/nest/index-type-inference.html
c# nest
Comments
Post a Comment