I have Set up a elastic search node on Azure and Implemented CRUD operations for the same using nest client while i have no problem inserting a new document in to the node but the inserted document is not visible for search though it can be seen in elasticsearch head in chrome extensions.

I have gone through documentation which suggest me to refresh the index after inserting yet no success in getting the inserted document in search results

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;
        }
    }

1 Answers

0
Chr0nicl3 On

Share your mapping, there could be a possibility that you disabled indexing for the field on which you are trying to search the document.