繁体   English   中英

使用NEST在Elasticsearch中创建类型

[英]Creating Types in Elasticsearch with NEST

因此,我仅使用一个类型(产品)构建了一个非常基本的Elastic示例,我能够使用自动映射来构建此示例,并且一切运行良好,现在我想对此进行扩展并添加更多我遇到问题的类型,但没有任何实质内容抛出异常可以使我了解出了什么问题。

class Product
    {

        public int ProductId { get; set; }
        public string Name { get; set; }
        public string ProductCode { get; set; }
        public string Barcode { get; set; }
        public Nullable<int> ProductCategoryId { get; set; }
        public int Length { get; set; }
        public int Height { get; set; }
        public int ProductTypeId { get; set; }
        public string Url { get; set; }
        public Nullable<int> ProductBrandId { get; set; }
        public int Width { get; set; }
        public string Html { get; set; }
        public string Description { get; set; }
        public string MetaTitle { get; set; }
        public string MetaKeywords { get; set; }
        public string MetaDescription { get; set; }
        public decimal CostPrice { get; set; }
        public Nullable<int> ProductBuyingPriceId { get; set; }
        public int DispatchTimeInDays { get; set; }
        public int LeadTimeInDays { get; set; }
        public string ManufacturerPartNumber { get; set; }
        public string Notes { get; set; }
        public int StockAvailable { get; set; }
        public decimal WeightKg { get; set; }
        public Nullable<int> SellingPriceGroupId { get; set; }
        public Nullable<decimal> ReviewRating { get; set; }
        public int ReviewRatingCount { get; set; }
        public bool NonReturnable { get; set; }
        public bool LimitedStock { get; set; }
        public Nullable<int> TaxRateId { get; set; }

        public virtual ProductCategory ProductCategory { get; set; }

    }

    class ProductCategory
    {
        public int ProductCategoryId { get; set; }
        public string Name { get; set; }
        public Nullable<int> ParentProductCategoryId { get; set; }
        public string FullPath { get; set; }
        public string Code { get; set; }
    }

        private void button1_Click(object sender, EventArgs e)
        {

            var des = new CreateIndexDescriptor("myindex")
                .Mappings(ms => ms
                .Map<Product>(m => m.AutoMap())
                .Map<ProductCategory>(m => m.AutoMap())
                );

            var res = elasticClient.CreateIndex(des);
            Output.AppendText(res.ToString());
            Output.AppendText(Environment.NewLine);
            Output.AppendText("Index Created");
            Output.AppendText(Environment.NewLine);


        }

如前所述,如果我仅添加它,那么如果添加产品类别,则效果很好。 TIA

谢谢您的答复正如Russ所说,我正在尝试使用多种无法使用的类型

暂无
暂无

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

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