c# - Bulk insert to ElasticSearch with NEST -


i try add 100k products elasticsearch, when try get: {"validation failed: 1: no requests added;"}

my code:

        var node = new uri("......");         var connectionpool = new sniffingconnectionpool(new[] { node });         var config = new connectionconfiguration(connectionpool)                     .sniffonconnectionfault(false)                     .sniffonstartup(false)                     .snifflifespan(timespan.fromminutes(10));         var client = new elasticsearchclient(config);          var allproducts = product.getproducts();         var spl = allproducts.split(100); // split 100 collections/requests          var coll = new list<elasticsearchresponse<dynamicdictionary>>();          foreach (var in spl)         {             var descriptor = new bulkdescriptor();              foreach (var product in i)             {                 descriptor.index<product>(op => op.document(product));             }              coll.add(client.bulk(descriptor));         } 

allproducts contains list of object:

public class product {  public int affiliatenr { get; set; }  public string affiliateproductid { get; set; }  public int brandnr { get; set; }  public string currency { get; set; }  public string indexid { get; set; }  public decimal price { get; set; }  public long productnr { get; set; }  public string title { get; set; } } 

so,

  1. where can set name of index?
  2. why did get, validation failed: 1: no requests added;?
  3. indexid id product. how tell elasticsearch use id? or must specify id?

refering previous problem, can use indexmany indexing data. per question in comment, can specify id elastic search use. see below example.

  elastictype(idproperty = "<fieldname>")]     public class classname     { 

if dont want specify id elastic search, create dummy field dummyid(nullable) , put in "idproperty". elastic search auto assign value if null.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -