Solr/SolrNet:如何在给定文档唯一 ID 的情况下更新文档?

发布于 2024-12-29 22:30:10 字数 345 浏览 3 评论 0原文

我需要与主索引过程分开更新 Solr 索引中每个文档的几个字段。根据文档,“Create”和“Update”被映射到“Add()”函数。 http://code.google.com/p/solrnet/wiki/CRUD

因此,如果我添加一个已经存在的文档,它会替换整个文档还是仅替换我指定的字段?

如果它将替换整个文档,那么我能想到的更新的唯一方法是通过唯一 ID 搜索文档,更新文档对象,然后再次“添加”它。由于所需的更新操作频率,这听起来不太可行。有更好的更新方法吗?

谢谢!

I need to update few fields of each document in Solr index separately from the main indexing process. According to documentation "Create" and "Update" are mapped onto the "Add()" function. http://code.google.com/p/solrnet/wiki/CRUD

So if I add a document which already exist, will it replace the entire document or just the fields that I have specified?

If it'll replace the entire document then the only way that I can think of in order to update is to search the document by unique id, update the document object and then "Add" it again. This doesn't sound feasible because of the frequency of update ops required. Is there a better way to update?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

洛阳烟雨空心柳 2025-01-05 22:30:10

不幸的是,Solr 目前不支持更新索引中给定文档的各个字段。您稍后描述的检索整个文档内容(从 Solr 或原始源)然后重新发送文档(通过 SolrNet 添加)的场景是更新 Solr 中文档的唯一方法。

请参阅上一个问题:更新 Solr 索引上的特定字段了解更多详细信息Solr 不支持单个字段更新,并且存在一个开放的 JIRA 问题来将此支持添加到 Solr。

Unfortunately, Solr does not currently support updating individual fields for a given document in the index. The later scenario you describe of retrieving the entire document contents (either from Solr or the original source) and then resending the document (adding via SolrNet) is the only way to update documents in Solr.

Please see the previous question: Update specific field on Solr index for more details about Solr not supporting individual field updates and an open JIRA issue for adding this support to Solr.

谁许谁一生繁华 2025-01-05 22:30:10

如果您需要频繁更新 SOLR 中的大量文档,您可能需要重新考虑整个解决方案。在使用 SOLR 并需要对文档进行大量频繁更新的典型解决方案中,通常的做法是将文档驻留在某些 SQL 或 NoSQL 数据库中,并在那里进行修改。然后,您使用 DIH 或类似的方法从数据库批量更新 SOLR 索引,可能只是删除索引并重新索引所有内容。 SOLR 可以非常快速地索引文档,因此这通常不是问题。

If you need to frequently update a lot of documents in SOLR, you might need to rethink your entire solution. In typical solutions that use SOLR and require lots of frequent updates to documents, the way it is usually done is that the documents reside in some SQL or NoSQL database, and they are modified there. Then you use DIH or something similar to bulk update the SOLR index from the database, possibly just dropping the index and re-indexing all content. SOLR can index documents very quickly so that is typically not a problem.

鱼忆七猫命九 2025-01-05 22:30:10

新版本的 Solr 现在支持文档的部分更新,例如 4.10 就做得很好。请查看以下页面了解更多信息:
https://cwiki.apache.org/confluence/display/solr /Updating+Parts+of+Documents

唯一的细节是您需要将字段声明为stored=true 以允许部分更新。

我还在本次培训中展示了如何做到这一点:
http://www.pluralsight.com/courses/enterprise-search-using -apache-solr

在此特定模块中:内容:模式、文档和索引

Partial updating of documents is now supported in the newer versions of Solr, for example 4.10 does pretty well. Please look at the following page for more information:
https://cwiki.apache.org/confluence/display/solr/Updating+Parts+of+Documents

The only detail is that you need to declare your fields as stored=true to allow for partial updates.

I also show how to do it in this training:
http://www.pluralsight.com/courses/enterprise-search-using-apache-solr

In this specific module: Content: Schemas, Documents and Indexing

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文