RoutingMissingException using NEST IndexMany<>
本文关键字:lt gt IndexMany using NEST RoutingMissingException | 更新日期: 2023-09-27 18:04:22
我一直在努力将我的ElasticSearch(ES(0.9代码转换为使用ES 1.0。这需要将NEST升级到最新的预发布版本。
我一直在尝试对一组子文档进行大容量索引。我已经将他们的映射设置为:
"stocks": {
"_parent": {
"type": "products"
},
"_timestamp": {
"enabled": true
},
"properties": {
"id": {
"type": "integer",
"index": "not_analyzed"
},
"stock": {
"type": "integer",
"index": "not_analyzed"
}
}
}
这是在ES 0.9中创建的。当我将其放入ES 1.0中时,它会自动添加一个"Required"设置为"true"的Routing属性。在谷歌上搜索表明,启用父子文档设置总是需要这样做,但当我检查0.9碎片中的文档时,该属性从未明确出现。
"好吧…"我心想。接下来,我有以下NEST的代码块:
var bulkParams = postQueue.Select(p => new BulkParameters<Stock>(p) { Parent = p.id.ToString()});
IElasticsearchResponse c = ec.IndexMany(bulkParams, null, "stocks").ConnectionStatus;
这将返回一个NullReferenceException。经过一些猜测,我将Id参数添加到BulkParameters:中
var bulkParams = postQueue.Select(p => new BulkParameters<Stock>(p) { Id = p.id.ToString(), Parent = p.id.ToString()});
这似乎有效,但请求从ES:返回错误响应
400带有JSON错误消息的错误请求:
error=RoutingMissingException[路由是[test_index]/[stock]/[xx]]所必需的
(其中xx是文档的id(
我假设我必须在某个地方插入一个路由字符串,但我不知道在哪里。我试着在BulkParameters中添加一个"Routing"参数,但根本不起作用。有人能提出建议吗?
已在NEST 1.0.0 beta 1
中删除对带包装BulkParameters
的IndexMany()
的支持
如果要使用具有更高级参数的批量,现在必须使用Bulk()
命令。
遗憾的是,测试版仍然与组件中的BulkParameters
类一起发货
这已经在开发分支中删除,并将在下一次测试版更新中发布。
因此,现在发生的情况是,您实际上是在为"bulkparameters``1``"
类型的文档编制索引,而不是使用适当的单个批量元数据集为"stock"
编制索引。
有关如何在为单个项目配置高级参数时使用Bulk()
一次索引多个对象的示例,请参阅此处。