Property mapping elasticsearch

When trying to read certain fields from ElasticSearch, I noticed that if I do not include a text attribute then it will not map the variable name to the field. It will read null for that specific field. Lets say I have a field in ES named ValueId of type text. In my model class I have public string ValueId {get; set;}. ValueId should have a value for that variable, but when I do not add a Elasticsearch Property Attribute i.e. [Text(Name = "ValueId")] it returns null.

Now if I have it as the following, then it will return a value for that variable.

[Text(Name = "ValueId")]
public string ValueId {get; set;}

My guess is because of the camel casing, is that correct?

On another note, is there a way I could set that property name (Name = "") dynamically? As in create a method to do this.

You seem to have repeated pretty much the same question from your earlier post. As answered there, the default configuration assumes that types are camel-case in JSON and the documentation I linked to provides guidance on changing that behaviour. You can also look at Fluent mapping for configuring the JSON name for properties which potentially could meet your dynamic requirement to set that when the application starts up for example.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.