You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GH-886: feat(opensearch): Add path prefix configuration support
Fixes: #886
Add ability to configure path prefix for OpenSearch API endpoints via properties.
This allows connecting to OpenSearch instances running behind a reverse proxy
with a non-root path, similar to Spring Elasticsearch's path-prefix property.
- Add pathPrefix property to OpenSearchVectorStoreProperties
- Apply pathPrefix to OpenSearchClient when configured
- Add documentation and unit tests
Signed-off-by: Soby Chacko <[email protected]>
Copy file name to clipboardExpand all lines: auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/main/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/OpenSearchVectorStoreAutoConfiguration.java
+5-1
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2023-2024 the original author or authors.
2
+
* Copyright 2023-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
Copy file name to clipboardExpand all lines: auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/main/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/OpenSearchVectorStoreProperties.java
+15
Original file line number
Diff line number
Diff line change
@@ -55,6 +55,13 @@ public class OpenSearchVectorStoreProperties extends CommonVectorStoreProperties
55
55
*/
56
56
privateDurationreadTimeout;
57
57
58
+
/**
59
+
* Path prefix for OpenSearch API endpoints. Used when OpenSearch is behind a reverse
60
+
* proxy with a non-root path. For example, if your OpenSearch instance is accessible
61
+
* at https://example.com/opensearch/, set this to "/opensearch".
62
+
*/
63
+
privateStringpathPrefix;
64
+
58
65
privateAwsaws = newAws();
59
66
60
67
publicList<String> getUris() {
@@ -121,6 +128,14 @@ public void setReadTimeout(Duration readTimeout) {
Copy file name to clipboardExpand all lines: auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/test/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/OpenSearchVectorStoreAutoConfigurationIT.java
+29-6
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2023-2024 the original author or authors.
2
+
* Copyright 2023-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
Copy file name to clipboardExpand all lines: spring-ai-docs/src/main/antora/modules/ROOT/pages/api/vectordbs/opensearch.adoc
+7
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,7 @@ spring:
105
105
similarity-function: cosinesimil
106
106
read-timeout: <time to wait for response>
107
107
connect-timeout: <time to wait until connection established>
108
+
path-prefix: <custom path prefix>
108
109
ssl-bundle: <name of SSL bundle>
109
110
aws: # Only for Amazon OpenSearch Service
110
111
host: <aws opensearch host>
@@ -128,6 +129,7 @@ Properties starting with `spring.ai.vectorstore.opensearch.*` are used to config
128
129
|`spring.ai.vectorstore.opensearch.similarity-function`| The similarity function to use | `cosinesimil`
129
130
|`spring.ai.vectorstore.opensearch.read-timeout`| Time to wait for response from the opposite endpoint. 0 - infinity. | -
130
131
|`spring.ai.vectorstore.opensearch.connect-timeout`| Time to wait until connection established. 0 - infinity. | -
132
+
|`spring.ai.vectorstore.opensearch.path-prefix`| Path prefix for OpenSearch API endpoints. Useful when OpenSearch is behind a reverse proxy with a non-root path. | -
131
133
|`spring.ai.vectorstore.opensearch.ssl-bundle`| Name of the SSL Bundle to use in case of SSL connection | -
132
134
|`spring.ai.vectorstore.opensearch.aws.host`| Hostname of the OpenSearch instance | -
133
135
|`spring.ai.vectorstore.opensearch.aws.service-name`| AWS service name | -
@@ -147,6 +149,11 @@ You can control whether the AWS-specific OpenSearch auto-configuration is enable
147
149
This fallback logic ensures that users have explicit control over the type of OpenSearch integration, preventing accidental activation of AWS-specific logic when not desired.
148
150
====
149
151
152
+
[NOTE]
153
+
====
154
+
The `path-prefix` property allows you to specify a custom path prefix when OpenSearch is running behind a reverse proxy that uses a non-root path.
155
+
For example, if your OpenSearch instance is accessible at `https://example.com/opensearch/` instead of `https://example.com/`, you would set `path-prefix: /opensearch`.
0 commit comments