Search code examples
c#.netnest

How can i create index on specific property using Nest in Elastic Search?


I want to make ID column as index able in Elastic Search with Nest Client.

public class Person
{
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

Solution

  • Try the following:

    [ElasticType(IdProperty = "Id", Name = "person")]    
    public class Person
    {
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }