--- title: "临时索引不应触发分片创建 - 如何解决此Elasticsearch异常" date: 2026-01-27 lastmod: 2026-01-27 description: "当Elasticsearch尝试为临时索引创建分片时出现此错误,这通常是由于配置错误或系统bug导致的。本文介绍如何解决此问题。" tags: ["临时索引", "分片创建", "索引配置"] summary: " 版本: 7.8-8.9 简要来说,当Elasticsearch尝试为临时索引创建分片时会发生此错误,这不是一个标准的操作。临时索引通常用于临时操作,不应该需要创建分片。这可能是由于配置错误或系统中的bug导致的。要解决此问题,您可以:1) 检查您的索引设置,确保不会为临时索引触发分片创建。2) 检查您的Elasticsearch版本并在必要时更新,因为这可能是已知问题,在后续版本中已修复。3) 调试您的代码以识别任何触发分片创建的错误操作。 日志上下文 # 日志"temp index should not trigger shard creation [{}]“的类名是 IndicesService.java。 我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入了解上下文的人参考: // double check that shard is not created. new IndexEventListener() { @Override public void beforeIndexShardCreated(ShardRouting shardRouting; Settings indexSettings) { assert false : "temp index should not trigger shard creation"; throw new ElasticsearchException("temp index should not trigger shard creation [{}]"; index); } @Override public void onStoreCreated(ShardId shardId) { assert false : "temp index should not trigger store creation"; " --- > **版本:** 7.8-8.9 简要来说,当Elasticsearch尝试为临时索引创建分片时会发生此错误,这不是一个标准的操作。临时索引通常用于临时操作,不应该需要创建分片。这可能是由于配置错误或系统中的bug导致的。要解决此问题,您可以:1) 检查您的索引设置,确保不会为临时索引触发分片创建。2) 检查您的Elasticsearch版本并在必要时更新,因为这可能是已知问题,在后续版本中已修复。3) 调试您的代码以识别任何触发分片创建的错误操作。 日志上下文 ----------- 日志"temp index should not trigger shard creation [{}]"的类名是[IndicesService.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入了解上下文的人参考: ```java // double check that shard is not created. new IndexEventListener() { @Override public void beforeIndexShardCreated(ShardRouting shardRouting; Settings indexSettings) { assert false : "temp index should not trigger shard creation"; throw new ElasticsearchException("temp index should not trigger shard creation [{}]"; index); } @Override public void onStoreCreated(ShardId shardId) { assert false : "temp index should not trigger store creation"; ```