【问题标题】:How can I perform solr atomic updates without a distributed update processor?如何在没有分布式更新处理器的情况下执行 solr 原子更新?
【发布时间】:2019-08-12 15:04:12
【问题描述】:

我在 kubernetes 中运行一个 solr 集群,我的组织管理我们自己的分片,而不是让 solr 自动分发文档。因此,我们在solrconfig.xml 中将DistributedUpdateProcessorFactory 替换为NoOpDistributingUpdateProcessorFactory。这发生在我的应用程序代码中,但我可以通过 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"

其中my_field1my_field2 都是多值字符串字段(我基本上想存储从我正在处理的一些数据中提取的字符串列表)。

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}}

所以我的问题是,为什么在没有分布式更新处理器的情况下禁止原子更新,有没有办法解决这个问题并将原子更新显式发送到各个分片?

【问题讨论】:

    标签: solr lucene solrcloud


    【解决方案1】:

    我的猜测是,由于原子更新需要先读取文档,更改字段,然后重新索引文档,因此 RunUpdateProcessor 只接收已经更改的文档,而没有任何更新/添加命令。

    这种转换是DistributedUpdateProcessorFactory 的责任,因为在正常设置中它必须从包含它的节点中检索文档,并应用更新,然后将其提交给RunUpdateProcessor

    您可以通过using the optimistic concurrency feature_version_ 自行实现此功能,或者为DistributedUpdateProcessorFactory 创建一个自定义替换,通过从索引中获取更新请求来解决它。

    旧 wiki 说 DistributedUpdateProcessor 是单核实例的无操作,但 that doesn't seem to be the case 不再是。

    但是,如果您在没有集群设置的情况下运行,DistributedUpdateProcessorFactory 不会执行与分发相关的任何操作 - 即,只要您已将 Solr 实例配置为独立的,那应该可以正常工作。这可能是架构问题 + solr 配置,而不是更新处理器的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-24
      • 2014-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多