简体   繁体   English

休眠搜索-删除Elasticsearch索引配置

[英]Hibernate search - delete Elasticsearch index config

We are using the mass indexer to create the index itself and the documents. 我们正在使用质量索引器来创建索引本身和文档。 We have our own versioning and the idea is to completely delete all documents and index configs when there is a new version and let mass indexer do its job. 我们有自己的版本控制,其想法是在有新版本时完全删除所有文档和索引配置,并让Mass Indexer进行工作。

The problem is that, differently from using Lucene directly, when we try to purge all the indexes, it only deletes the documents, it doesn't delete the index config, which ends up in conflicts when trying to modify an existing field. 问题在于,与直接使用Lucene不同,当我们尝试清除所有索引时,它仅删除文档,而不删除索引配置,这在尝试修改现有字段时会导致冲突。

Is there a way to do this through Hibernate Search or do we need to use the DELETE method on our cluster directly? 有没有办法通过Hibernate Search做到这一点,还是我们需要直接在集群上使用DELETE方法?

I assume you run this mass indexing job as part of your migration procedure from one version of your application to the next. 我假设您在从一个应用程序版本到另一个版本的迁移过程中运行此批量索引作业。 If so, in the one-time job that triggers reindexing, you could start Hibernate with the following setting: 如果是这样,则在触发重新索引的一次性作业中,可以使用以下设置启动Hibernate:

hibernate.search.default.elasticsearch.index_schema_management_strategy drop-and-create

Then, on startup Hibernate Search will drop the index completely, along with its mapping, and recreate it. 然后,在启动时,Hibernate Search将完全删除索引及其映射,然后重新创建它。

Be careful though, this is fine only if you execute the mass indexing in a dedicated program. 但是请小心 ,这只有在专用程序中执行质量索引时才可以。 Your application should probably not be started with this setting, as it will cause it to drop the indexes on every startup (eg if your had to restart your server for whatever reason). 您的应用程序可能不应该使用此设置启动,因为它将导致它在每次启动时都删除索引(例如,如果出于某种原因必须重新启动服务器)。

Source: the official documentation 资料来源: 官方文件

On a side note: 附带说明:

The problem is that, differently from using Lucene directly, when we try to purge all the indexes, it only deletes the documents, it doesn't delete the index config, which ends up in conflicts when trying to modify an existing field. 问题在于,与直接使用Lucene不同,当我们尝试清除所有索引时,它仅删除文档,而不删除索引配置,这在尝试修改现有字段时会导致冲突。

This is actually the same behavior as the Lucene integration: when you purge a Lucene index, the index file stays the same, it's just that any content has been removed. 这实际上与Lucene集成的行为相同:清除Lucene索引时,索引文件保持不变,只是所有内容都已删除。 The main difference is that Elasticsearch has some index metadata (the mapping), while "raw" Lucene doesn't. 主要区别是Elasticsearch具有一些索引元数据(映射),而“原始” Lucene没有。

However, it is true that the current behavior is rather annoying in your case. 但是,在您的情况下,当前的行为确实很烦人。 We will try to address it in the future, probably as part of HSEARCH-2861 . 将来,我们可能会尝试将其作为HSEARCH-2861的一部分进行处理

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM