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
@@ -233,6 +234,147 @@ is converted into the following Azure OData link:https://learn.microsoft.com/en-
233
234
$filter search.in(meta_country, 'UK,NL', ',') and meta_year ge 2020
234
235
----
235
236
237
+
== Custom Field Names
238
+
239
+
By default, the Azure Vector Store uses the following field names in the Azure AI Search index:
240
+
241
+
* `content` - for document text
242
+
* `embedding` - for vector embeddings
243
+
* `metadata` - for document metadata
244
+
245
+
However, when working with existing Azure AI Search indexes that use different field names, you can configure custom field names to match your index schema. This allows you to integrate Spring AI with pre-existing indexes without needing to modify them.
246
+
247
+
=== Use Cases
248
+
249
+
Custom field names are particularly useful when:
250
+
251
+
* **Integrating with existing indexes**: Your organization already has Azure AI Search indexes with established field naming conventions (e.g., `chunk_text`, `vector`, `meta_data`).
252
+
* **Following naming standards**: Your team follows specific naming conventions that differ from the defaults.
253
+
* **Migrating from other systems**: You're migrating from another vector database or search system and want to maintain consistent field names.
254
+
255
+
=== Configuration via Properties
256
+
257
+
You can configure custom field names using Spring Boot application properties:
IMPORTANT: When using an existing index with custom field names, set `initialize-schema=false` to prevent Spring AI from trying to create a new index with the default schema.
273
+
274
+
=== Configuration via Builder API
275
+
276
+
Alternatively, you can configure custom field names programmatically using the builder API:
277
+
278
+
[source,java]
279
+
----
280
+
@Bean
281
+
public VectorStore vectorStore(SearchIndexClient searchIndexClient, EmbeddingModel embeddingModel) {
.initializeSchema(true) // Create new index with custom field names
366
+
.contentFieldName("text_content")
367
+
.embeddingFieldName("content_vector")
368
+
.metadataFieldName("doc_metadata")
369
+
.filterMetadataFields(List.of(
370
+
MetadataField.text("category"),
371
+
MetadataField.text("author")))
372
+
.build();
373
+
}
374
+
----
375
+
376
+
This will create a new Azure AI Search index with your custom field names, allowing you to establish your own naming conventions from the start.
377
+
236
378
== Accessing the Native Client
237
379
238
380
The Azure Vector Store implementation provides access to the underlying native Azure Search client (`SearchClient`) through the `getNativeClient()` method:
0 commit comments