可以从 Solr 索引中的文档中删除字段吗?

发布于 2024-10-14 15:26:12 字数 72 浏览 9 评论 0 原文

我有一个很大的索引,在索引过程中出现了错误。因此,为了避免需要几天时间的重新索引,我想简单地删除特定字段并重新索引。有什么建议吗?

I have a big index, and during the indexation process there was an error. So to avoid reindexing which takes several days, I want to simply delete specific field and reindex. Is there any suggestion?

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

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

发布评论

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

评论(7

演出会有结束 2024-10-21 15:26:12

如果您使用 Solr 4,则可以使用 AtomicUpdate http://wiki.apache.org/solr/Atomic_Updates
更轻松地删除字段。例如:

curl http://localhost:8983/solr/update?commit=true -H 'Content-type:application/json' --data-binary '[{"id": "630911fa-711a-3944-b1d2-cda6857f9827", "field_to_be_removed": {"set": null}}]'

If you're using Solr 4, you can use AtomicUpdate http://wiki.apache.org/solr/Atomic_Updates
to remove a field much more easily. For example:

curl http://localhost:8983/solr/update?commit=true -H 'Content-type:application/json' --data-binary '[{"id": "630911fa-711a-3944-b1d2-cda6857f9827", "field_to_be_removed": {"set": null}}]'
捂风挽笑 2024-10-21 15:26:12

如果您存储了其余字段,即 stored="true ",则可以执行此操作。如下所示,通过设置 null 值。

<add>
  <doc>
    <!-- your unique key field -->
    <field name="employeeId">05991</field>  
    <!-- what ever field you want to delete -->
    <field name="skills" update="set" null="true" /> 
  </doc>
</add>

来源:https://wiki.apache.org/solr/UpdateXmlMessages

you can do this if your rest of the fields are stored i.e stored="true ".as follows by setting null value.

<add>
  <doc>
    <!-- your unique key field -->
    <field name="employeeId">05991</field>  
    <!-- what ever field you want to delete -->
    <field name="skills" update="set" null="true" /> 
  </doc>
</add>

source:https://wiki.apache.org/solr/UpdateXmlMessages

情绪失控 2024-10-21 15:26:12

你不能。解决方案是获取文档,暂时存储在内存中,删除它,更新所需字段(删除、添加),然后将文档添加回索引。

You cannot. The solution would be to get the document, store temporarily in the memory, delete it, update the required field (remove, add) and then add the document back to the index.

若能看破又如何 2024-10-21 15:26:12

您可以通过 id 删除索引文档。如果您想通过删除字段来更改架构,那么是的,您必须重新索引。

You can delete the indexed document by it's id. If you want to change the schema by removing a field, then yes, you would have to reindex.

一生独一 2024-10-21 15:26:12

您可以使用命令delete和如下查询来删除所有索引:

java -Ddata=args -Dcommit=yes -jar post.jar "<delete><query>*:*</query></delete>"

使用参数-Dcommit强制更新索引,因此,请小心不要在不需要时删除所有文档。

You can delete all the index using the command delete and a query like this:

java -Ddata=args -Dcommit=yes -jar post.jar "<delete><query>*:*</query></delete>"

Using the argument -Dcommit force to update the index, so, be careful not deleting all documents when you dont want.

一身仙ぐ女味 2024-10-21 15:26:12

使用 solr 8.11.2,

curl 'http://localhost:8983/solr/solr/schema' -d '{"delete-field":{"name":"${field_name}"}}'

With solr 8.11.2,

curl 'http://localhost:8983/solr/solr/schema' -d '{"delete-field":{"name":"${field_name}"}}'
久而酒知 2024-10-21 15:26:12

您可以删除 Solr 中某个字段的索引值,但不能删除该字段。

如果您确实想在索引时删除特定字段,那么您应该在索引文档之前在 schema.xml 文件中配置该字段。

You can delete indexed value w.r.t. a field in Solr but not the field.

If you really want to delete a specific field while indexing then you should configure the field in schema.xml file before indexing document.

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