主题
Azure AI Search
https://azure.microsoft.com/en-us/products/ai-services/ai-search/
Maven 依赖
xml
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-azure-ai-search</artifactId>
<version>1.22.0-beta32</version>
</dependency>1
2
3
4
5
2
3
4
5
API
AzureAiSearchEmbeddingStore—— 支持向量搜索AzureAiSearchContentRetriever—— 支持向量、全文、混合搜索及重排序
来自自带(bring-your-own)索引的元数据
默认情况下,AzureAiSearchContentRetriever 和 AzureAiSearchEmbeddingStore 从它们自己写入的 嵌套 metadata 字段读取片段元数据。当你把它们指向一个预先存在的索引 (createOrUpdateIndex(false))、而其字段存储在文档根层时,可在任一 builder 上使用 metadataFieldNames 来列出需要作为元数据暴露的顶层字段:
java
ContentRetriever retriever = AzureAiSearchContentRetriever.builder()
.endpoint(endpoint)
.tokenCredential(tokenCredential)
.indexName(indexName)
.createOrUpdateIndex(false)
.queryType(AzureAiSearchQueryType.FULL_TEXT)
.metadataFieldNames(List.of("sourcepage", "weburl", "topic", "role"))
.maxResults(4)
.build();1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
当所列字段的值是 Metadata 支持的类型 (String、Integer、Long、Float、Double 或 UUID)时,它会被复制到片段的 Metadata 中。缺失、为 null 或属于其他 类型(例如嵌入向量)的字段会被跳过。字段必须在 Azure 索引中被标记为可检索,其值才会被返回;并且当某个字段名与嵌套 metadata 中的键匹配时, 顶层值优先。
该选项仅配置元数据提取;索引的核心 ID、 内容、向量与语义搜索字段的既有要求保持不变。