У меня настроен эластичный поисковый узел в Azure и реализованы операции CRUD для того же клиента с использованием nest, пока у меня нет проблем с вставкой нового документа в узел, но вставленный документ не виден для поиска, хотя его можно увидеть в упругой головке в хромированных расширениях
Я просмотрел документацию, в которой предлагалось обновить индекс после вставки, но пока не удалось получить вставленный документ в результатах поиска
public bool AddNewProductEL( string indexName, ProductTable product)
{
bool status = false;
try
{
List<ProductTable> FinalList = new List<ProductTable>();
ProductTable item = new ProductTable();
item.ProductID = product.ProductID;
item.ProductName = product.ProductName;
string packing = (from t in entity.Packings where t.PackingID == product.PackingFID select t.PackingName).FirstOrDefault();
item.PackingName = packing == null ? "" : packing;
string manu = (from t in entity.Manufacturers where t.ManufacturerID == product.ManufacturerFID select t.ManufacturerName).FirstOrDefault();
item.Manufacturername = manu == null ? "" : manu;
item.ProductDescription = product.ProductDescription == null ? "" : product.ProductDescription;
string brand = (from t in entity.Brands where t.BrandID == product.BrandFID select t.BrandName).FirstOrDefault();
item.Brandname = brand == null ? "" : brand;
item.ProductTypeFID = product.ProductTypeFID;
FinalList.Add(item);
foreach (var dt in FinalList)
{
var response = elasticClient.Index(dt, i => i
.Index(indexName)
.Type(TypeName.From<ProductTable>())
.Id(dt.ProductID)
.Refresh(Refresh.True));
if (response.IsValid) { status = true; }
var r = elasticClient.RefreshAsync(indexName);
}
// System.Web.HttpContext.Current.Response.Write(" inserting product in elasticsearch status : - " + status);
return status;
}
catch (Exception e)
{
status = false;
// System.Web.HttpContext.Current.Response.Write("error inserting product in elasticsearch : - " + e.Message + " inner exception :-" + e.InnerException);
return status;
}
}