According to the documentation on Elasticsearch.Net you can provide your own type that Elasticsearch.Net will deserialize into, like this:
ElasticsearchLowLevelClient.Index<MyCustomType>(indexName, type, id, obj);
Which only works if the type is defined like this:
public class ElasticsearchResult
{
public string _index { get; set; }
public string _type { get; set; }
public string _id { get; set; }
public int _version { get; set; }
public string result { get; set; }
public Shard _shards { get; set; }
public bool created { get; set; }
}
But I want this type to look like this:
public class ElasticsearchResult
{
public string Index { get; set; }
public string Type { get; set; }
public string Id { get; set; }
public int Version { get; set; }
public string Result { get; set; }
public Shard Shards { get; set; }
public bool Created { get; set; }
}
How do I achieve that? I have tried to use the JsonProperty attribute [JsonProperty(PropertyName = "_shards")]
, but that does not work.