I have a class that represents the data I want to store in ES that contains mostly integers. However, I don't want to index fields which are a particular value (in this case, 0). I'm trying to get the API to completely disregard fields that are 0 so they don't get indexed.
Currently I'm doing this, but it doesn't work (the zeroes are indexed anyway):
class ElasticDataRepresentation
{
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
[Nest.Number(Name = "postid", NullValue = 0)]
public uint PostID { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
[Nest.Number(Name = "datapointid", NullValue = 0)]
public int DataPointID { get; set; }
}
and then run the indexing in bulk with the following code. Everything works as expected except that I can't get it to disregard the zeroes:
var descriptor = new Nest.BulkDescriptor();
foreach (var pi in items)
{
//Construct the ID
string id = pi.DataPointID.ToString() + "_" + pi.PostID;
//Add this document to the bulk request
descriptor.Index<ElasticDataRepresentation>(op => op.Document(pi).Id(id).Index(Model.ElasticSearchIndexName).Type(Model.ElasticSearchTypeName));
}
//Execute the bulk index request
var result = client.Bulk(descriptor);
Any ideas how this can be resolved? Thanks!