C# NEST-IndexMany不';t索引我的对象
我使用NEST for elasticsearch已经有一段时间了,到目前为止,我一直使用常规的ElasticSearchClient.Index(…)函数,但现在我想在批量操作中为许多项编制索引 我找到了IndexMany(…)函数,但我必须做些错误的事情,因为弹性搜索数据库没有像常规索引(…)函数那样添加任何内容 有人知道吗 提前谢谢 如果使用C#应该创建一个要插入的对象列表,然后调用IndexMany函数 例如:C# NEST-IndexMany不';t索引我的对象,c#,
elasticsearch,nest,C#,
elasticsearch,Nest,我使用NEST for elasticsearch已经有一段时间了,到目前为止,我一直使用常规的ElasticSearchClient.Index(…)函数,但现在我想在批量操作中为许多项编制索引 我找到了IndexMany(…)函数,但我必须做些错误的事情,因为弹性搜索数据库没有像常规索引(…)函数那样添加任何内容 有人知道吗 提前谢谢 如果使用C#应该创建一个要插入的对象列表,然后调用IndexMany函数 例如: List<Business> businessList = ne
List<Business> businessList = new List<Business>();
#region Fill the business list
...............................
#endregion
if (businessList.Count == 1000) // the size of the bulk.
{
EsClient.IndexMany<Business>(businessList, IndexName);
businessList.Clear();
}
List businessList=newlist();
#区域填写业务列表
...............................
#端区
if(businessList.Count==1000)//大容量的大小。
{
EsClient.IndexMany(businessList,IndexName);
businessList.Clear();
}
最后再检查一遍
if (businessList.Count > 0)
{
EsClient.IndexMany<Business>(businessList, IndexName);
}
if(businessList.Count>0)
{
EsClient.IndexMany(businessList,IndexName);
}
我发现了问题。我必须在调用IndexMany时指定索引名
var res = ElasticClient.CreateIndex("pages", i => i.Mappings(m => m.Map<ESPageViewModel>(mm => mm.AutoMap())));
var page = new ESPageViewModel
{
Id = dbPage.Id,
PageId = dbPage.PageId,
Name = dbPage.Name,
Options = pageTags,
CustomerCategoryId = saveTagOptions.CustomerCategoryId,
Link = dbPage.Link,
Price = dbPage.Price
};
var pages = new List<ESPageViewModel>() { page };
var res2 = ElasticClient.IndexManyAsync<ESPageViewModel>(pages, "pages");
var res=ElasticClient.CreateIndex(“页面”,i=>i.Mappings(m=>m.Map(mm=>mm.AutoMap()));
var page=新的ESPageViewModel
{
Id=dbPage.Id,
PageId=dbPage.PageId,
Name=dbPage.Name,
选项=页面标签,
CustomerCategoryId=saveTagOptions.CustomerCategoryId,
Link=dbPage.Link,
Price=dbPage.Price
};
var pages=new List(){page};
var res2=ElasticClient.indexmanyanc(pages,“pages”);
这正如预期的那样有效。我想我可以在配置中指定一个默认索引名,以避免为IndexMany调用指定索引。您同时尝试索引多少“事物”?尺寸是多少?HTTP内容长度限制实施了大约100MB的大小限制。在我的测试中,我只使用了2个项目,没有一个项目在我的索引中结束。我知道限制:)并且我也没有从IndexMany(…)函数中得到任何错误:/response上的
.DebugInformation
属性说了什么?