Search code examples
c#elasticsearchnest

Exclude property from being indexed


I have created below object which will be mapped to ElasticSearch type. I would like to exclude the UnivId property from being indexed:

[ElasticType(Name = "Type1")]
public class Type1
{
    // To be ignored
    public string UnivId { get; set; }

    [ElasticProperty(Name="Id")]
    public int Id { get; set; }

    [ElasticProperty(Name = "descSearch")]
    public string descSearch { get; set; }
}

Solution

  • You should be able to set the OptOut value of the ElasticProperty attribute, like the following:

     [ElasticProperty(OptOut = true)]
     public string UnivId { get; set; }