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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4802620/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 08:05:27  来源:igfitidea点击:

Can you delete a field from a document in Solr index?

javasolrfield

提问by user3111525

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?

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

采纳答案by ck reddy

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.

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

回答by Shao-Chuan Wang

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

如果您使用的是 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}}]'

回答by ck reddy

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

如果您的其余字段被存储,即 .stored="true "如下,您可以通过设置空值来执行此操作。

<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

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

回答by Joyce

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.

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

回答by josegil

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

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

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

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

使用参数-Dcommitforce 更新索引,因此,请注意不要在不需要时删除所有文档。

回答by Veeresh123

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

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

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

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