nest - _id is not getting autogenerated in Elasticsearch -


i have simple list of documents of type salesorder. while inserting them elastic search, _id taking value of salesorderid. need autogenerated. below class

    public class salesorder     {         [xmlelement("id")]         public long salesorderid { get; set; }          public long customerid { get; set; }          public datetime? bookeddate { get; set; }          public long salesorderno { get; set; }      } 

this how inserting docs in elastic search

            elasticclient elasticclient = createelasticclient(indexname);              if (!elasticclient.indexexists(i => i.index(indexname)).exists)             {                 elasticclient.createindex(indexname, s => s.addmapping<t>(m => m                 .mapfromattributes()));             }              // create indexes             var response = elasticclient.indexmany<t>(documents); 

you can specify id field es use this:

[elastictype(name = "salesorder", idproperty = "id")] public class salesorder {             public string id {get;set;}//this used internally es      public long salesorderid { get; set; }      public long customerid { get; set; }      public datetime? bookeddate { get; set; }      public long salesorderno { get; set; }  } 

note: if populate id use value insert es. if leave null es create automatically you.

also, if salesorder class specific elasticsearch should not have xmlelement tag on it.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -