简体   繁体   English

将同一文档重新索引/添加回 Solr 内核时,如何防止版本冲突?

[英]How do I prevent a version conflict when reindexing/adding the same document back into the Solr core?

I have a Solr core containing 60k documents.我有一个包含 60k 个文档的 Solr 内核。 I have updated the field types in the schema.xml and I do not want to delete the Solr core for reindexing.我已经更新了 schema.xml 中的字段类型,并且我不想删除 Solr 核心以进行重新索引。 I am trying to retrieve the documents with a Solr search and then try to add that same document with that same id back into Solr.我正在尝试使用 Solr 搜索来检索文档,然后尝试将具有相同 ID 的相同文档添加回 Solr。 In doing this, I get a version conflict.在这样做时,我遇到了版本冲突。

Example: I retrieve one document using a Pysolr search request.示例:我使用 Pysolr 搜索请求检索一个文档。 The document looks like this:该文档如下所示:

doc = {
        "type":"person",
        "lastname":"Johnson",
        "firstname":"Bobby",
        "id":"person_abcd",
        "_version_":1691404871556661248}

The above document still exists in Solr and I do not want to change it. Solr 中仍然存在上述文档,我不想更改它。 I want to reindex it/add it again back into Solr because the field types in the schema.xml have changed.我想重新索引它/再次将其添加回 Solr 因为 schema.xml 中的字段类型已更改。

When I do:当我做:

import pysolr

core = pysolr.Solr('http://localhost:10000/solr/core', always_commit=True)
core.add(doc)

I get the following error:我收到以下错误:

pysolr.SolrError: Solr responded with an error (HTTP 409): [Reason: version conflict for person_abcd expected=1691404871556661248 actual=1691426574942863360]

Why does the 'actual' version change and does not stay as the 'expected' version?为什么“实际”版本会发生变化,而不是“预期”版本?

How can I solve this (examples are appreciated)?我该如何解决这个问题(赞赏示例)?

The _version_ field is used internally by Solr to manage partial update and update log features. Solr 在内部使用_version_字段来管理部分更新和更新日志功能。 You should not include it in your documents when reindexing.重新索引时不应将其包含在文档中。 Just remove it.只需将其删除。

If you need Solr Optimistic Concurrency feature, in this case the _version_ must be specified as part of the update command in the request, not in the documents.如果您需要 Solr 乐观并发功能,在这种情况下, _version_必须在请求中指定为更新命令的一部分,而不是在文档中。

暂无
暂无

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

相关问题 当添加具有完全相同的字段和值的文档时,Solr(Lucene)在内部做什么? - What does Solr (Lucene) do internally when adding a document which exists with exactly the same fields and values? 如何更新 Solr PHP 中的文档? - How do I update a document in Solr PHP? 如何将xml文档发布到solr? - How do I POST an xml document into solr? SOLR-在将字段值添加到SOLR时如何从文档中提取字段值? - SOLR - How do I pull field values from documents when adding them to SOLR? Solr:恢复为旧模式并停止重新索引 - Solr: Reverting back to an old schema and stop reindexing 如何在同一子文档上查询和筛选具有多个条件的Solr 6.4子文档? - How do I query and filter Solr 6.4 child documents with multiple criteria on the same child document? 如何防止Solr添加页眉和页脚? - How can I prevent Solr from adding headers and footers? 将核心从Solr 4.6迁移到Solr 4.10,而无需重新索引 - Migrating a core from Solr 4.6 to Solr 4.10, without reindexing 当索引被锁定时,如何让Solr备份 <unlockOnStartup> 真的不起作用? - How do I get Solr back up when indexes are locked and <unlockOnStartup>true doesn't work? 向 Solr 核心添加字段时,为什么会出现“ManagedIndexSchema Error persisting managed schema =&gt; FileNotFoundException: (Access is denied)”? - Why do I get "ManagedIndexSchema Error persisting managed schema => FileNotFoundException: (Access is denied)" when adding a field to a Solr core?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM