--- title: "设置次要端点时需要主要端点——如何解决此Elasticsearch异常" date: 2026-01-24 lastmod: 2026-01-24 description: "在Elasticsearch中设置了次要端点但未设置主要端点时,会抛出此异常。本文介绍了该错误的原因、版本信息、详细说明以及源代码上下文,帮助您快速定位和解决问题。" tags: ["Azure存储", "端点配置", "设置异常"] summary: "适用版本: 8.8-8.9 此错误发生的原因是在 Elasticsearch 中设置了次要端点(secondary endpoint),但没有设置主要端点(primary endpoint)。Elasticsearch 需要主要端点才能正常运行,只有在已经配置主要端点的情况下,才能设置次要端点。 要解决此问题,请确保在设置次要端点之前先设置主要端点。或者,如果次要端点不是必需的,可以将其移除。同时,请检查您的配置文件或设置,确保主要端点已正确定义且可访问。 日志上下文 # 日志 “A primary endpoint is required when setting a secondary endpoint” 的类名是 AzureStorageSettings.java。我们从 Elasticsearch 源代码中提取了以下内容,以供那些需要深入了解上下文的用户参考: if (hasEndpointSuffix && hasSecondaryEndpoint) { throw new SettingsException("Both an endpoint suffix as well as a secondary endpoint were set"); } if (hasEndpoint == false && hasSecondaryEndpoint) { throw new SettingsException("A primary endpoint is required when setting a secondary endpoint"); } if (hasEndpointSuffix) { connectionStringBuilder." --- > **适用版本:** 8.8-8.9 此错误发生的原因是在 Elasticsearch 中设置了次要端点(secondary endpoint),但没有设置主要端点(primary endpoint)。Elasticsearch 需要主要端点才能正常运行,只有在已经配置主要端点的情况下,才能设置次要端点。 要解决此问题,请确保在设置次要端点之前先设置主要端点。或者,如果次要端点不是必需的,可以将其移除。同时,请检查您的配置文件或设置,确保主要端点已正确定义且可访问。 ## 日志上下文 日志 "A primary endpoint is required when setting a secondary endpoint" 的类名是 [AzureStorageSettings.java](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/)。我们从 Elasticsearch 源代码中提取了以下内容,以供那些需要深入了解上下文的用户参考: ```java if (hasEndpointSuffix && hasSecondaryEndpoint) { throw new SettingsException("Both an endpoint suffix as well as a secondary endpoint were set"); } if (hasEndpoint == false && hasSecondaryEndpoint) { throw new SettingsException("A primary endpoint is required when setting a secondary endpoint"); } if (hasEndpointSuffix) { connectionStringBuilder.append(";EndpointSuffix=").append(endpointSuffix); } ```