簡體   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