繁体   English   中英

无法在弹性搜索节点中搜索插入的文档

[英]Unable to search inserted Documents in Elastic Search Node

我已经在Azure上设置了一个弹性搜索节点并使用嵌套客户端实现了相同的CRUD操作,而我在将新文档插入节点时没有问题,但插入的文档对于搜索是不可见的,尽管可以在elasticsearch head中看到在chrome扩展中。

我已经阅读了文档,建议我在插入后刷新索引但是没有成功地在搜索结果中获取插入的文档

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

共享您的映射,您可能有可能禁用了您尝试搜索文档的字段的索引。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM