solr - 如何在没有分布式更新处理器的情况下执行 solr 原子更新?
问题描述
我在 kubernetes 中运行一个 solr 集群,我的组织管理我们自己的分片,而不是让 solr 自动分发文档。因此我们DistributedUpdateProcessorFactory
在NoOpDistributingUpdateProcessorFactory
. solrconfig.xml
这发生在我的应用程序代码中,但我可以通过 shell 的简单卷曲重现该行为:
# send an update to a document in shard 0 that adds a value to each field
curl -X POST --header "Content-Type:application/json" --data "[{'id': 'my_doc_id', 'my_field1': {add: ['foo']}, 'my_field2': {add: ['bar']}]" "http://solr-0.solr-headless.default.svc.cluster.local:8983/solr/my_collection/update?commit=false"
# commit the update to the shard (along with updates to other docs I might have sent)
curl -X GET "http://solr-0.solr-headless.default.svc.cluster.local:8983/solr/my_collection/update?commit=true"
Wheremy_field1
和my_field2
are 都是多值字符串字段(我基本上想存储从我正在处理的一些数据中提取的字符串列表)。
solr 给出的响应是:
{
"responseHeader":{
"status":400,
"QTime":3},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"RunUpdateProcessor has received an AddUpdateCommand containing a document that appears to still contain Atomic document update operations, most likely because DistributedUpdateProcessorFactory was explicitly disabled from this updateRequestProcessorChain",
"code":400}}
所以我的问题是,为什么在没有分布式更新处理器的情况下禁止原子更新,有没有办法解决这个问题并将原子更新显式发送到各个分片?
解决方案
我的猜测是,由于原子更新需要先读取文档,更改字段然后重新索引文档,因此 RunUpdateProcessor 仅接收已更改的文档而没有任何更新/添加命令。
这种转换是 的责任DistributedUpdateProcessorFactory
,因为在正常设置中,它必须从包含它的节点中检索文档,并应用更新,然后将其提交给RunUpdateProcessor
。
您可以通过使用乐观并发特性来自己实现此功能_version_
,或者创建一个自定义替换,DistributedUpdateProcessorFactory
通过从索引中获取更新请求来解决更新请求。
旧的 wiki 说DistributedUpdateProcessor
对于单核实例来说是无操作的,但似乎不再是这种情况了。
但是如果你在没有集群设置的情况下运行,DistributedUpdateProcessorFactory 不会做任何与分发相关的事情——也就是说,只要你将 Solr 实例配置为独立的,那应该可以正常工作。这可能是架构问题 + solr 配置,而不是更新处理器的问题。
推荐阅读
- c# - Xamarin .NET API 使用 Refit 错误 Refit.ApiException
- asp.net-core - Visual Studio 2019 QuickWatch 在 ASP.NET Core Blazor WebAssembly Program.cs 文件中显示无法评估(Unable to evaluate)
- python - 从网页抓取时出现 IndexError
- python - 如何使用 django-two-factor-auth 在 django 中为现有用户获取 OTP 令牌
- javascript - UnhandledPromiseRejectionWarning: RangeError [EMBED_FIELD_VALUE]: MessageEmbed 字段值不能为空
- android - RxBLELibraries/RxAndroidBle:状态为 8(GATT_INSUF_AUTHORIZATION 或 GATT_CONN_TIMEOUT)
- angular - 拖动事件触发了几秒钟
- c# - meshbuilder AddPolygon() 方法的奇怪行为的原因是什么?
- automation - 如何从空手道 API 自动化中的功能文件中验证针对多个数据库实例的 API 响应?
- server - Recaptcha 将 Formmail 的“电子邮件”(发件人)字段替换为我的服务器地址。如果没有 Recaptcha,From 字段可以正常工作。为什么?