cerco di aggiungere 100k prodotti elasticsearch, ma quando provo ottengo: { "Convalida non riuscita: 1: nessuna richiesta aggiunto;"}inserimento di massa per elasticsearch con NEST
Il mio codice:
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 contiene un elenco di questo oggetto:
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; }
}
Quindi,
- Dove posso impostare il nome dell'indice?
- Perché ho ricevuto, Convalida non riuscita: 1: nessuna richiesta aggiunta?
- IndexId è il mio ID per il prodotto. Come faccio a dire a Elasticsearch di usare questo ID? O devo specificare un ID?
perché non usare IndexMany? –
grazie. Ora ho: SPl.Seleziona (I => Client.IndexMany (I, "prodotti")) E funziona. Ma: IndexId è il mio ID per il prodotto. Come faccio a dire a Elasticsearch di usare questo ID? O devo specificare un ID? – mrcode
Rinominare il campo IndexId su Id e elasticsearch userà questo per convenzione come id del documento. – Manolis