próbuję dodać 100k produkty elasticsearch, ale gdy próbuję uzyskać: { "Validation Failed: 1: brak żądania dodanej;"}Luzem wkładka do ElasticSearch z NEST
Mój kod:
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 into 100 collections/requests
var COll = new List<ElasticsearchResponse<DynamicDictionary>>();
foreach (var I in SPl)
{
var Descriptor = new BulkDescriptor();
foreach (var Product in I)
{
Descriptor.Index<Product>(op => op.Document(Product));
}
COll.Add(Client.Bulk(Descriptor));
}
Allproducts zawiera listę obiektu:
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; }
}
Więc
- Gdzie mogę ustawić nazwę indeksu?
- Dlaczego otrzymałem, Niepowodzenie sprawdzania poprawności: 1: brak dodanych żądań ;?
- IndexId to mój identyfikator produktu. Jak mogę powiedzieć Elasticsearch, aby używał tego identyfikatora? Czy muszę podać identyfikator?
dlaczego nie używając IndexMany? –
thanx. Mam teraz: SPl.Selekt (I => Klient.IndexMany (I, "produkty")) I działa. Ale: IndexId to mój identyfikator produktu. Jak mogę powiedzieć Elasticsearch, aby używał tego identyfikatora? Czy muszę podać identyfikator? – mrcode
Zmień nazwę pola IndexId na Id, a elasticsearch użyje tej konwencji zgodnie z konwencją jako id dokumentu. – Manolis