PageSourceSearch

https://java2ai.com/assets/js/80058358.e36ef817.js

js java2ai.com collected 2026-10-03 21:35:55 UTC 20,127 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkspring_ai_alibaba_website=self.webpackChunkspring_ai_alibaba_website||[]).push([[5466],{28453:(e,n,r)=>{r.d(n,{R:()=>c,x:()=>a});var i=r(96540);const t={},s=i.createContext(t);function c(e){const n=i.useContext(s);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:c(e.components),i.createElement(s.Provider,{value:n},e.children)}},56188:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>d,contentTitle:()=>a,default:()=>h,frontMatter:()=>c,metadata:()=>i,toc:()=>l});const i=JSON.parse('{"id":"rag/vectordbs/analyticdb","title":"AnalyticDB","description":"\u672c\u8282\u5c06\u6307\u5bfc\u60a8\u8bbe\u7f6e AnalyticDB VectorStore \u6765\u5b58\u50a8\u6587\u6863\u5d4c\u5165\u5e76\u6267\u884c\u76f8\u4f3c\u6027\u641c\u7d22\u3002","source":"@site/integration/rag/vectordbs/analyticdb.md","sourceDirName":"rag/vectordbs","slug":"/rag/vectordbs/analyticdb","permalink":"/integration/rag/vectordbs/analyticdb","draft":false,"unlisted":false,"editUrl":"https://github.com/spring-ai-alibaba/website/tree/main/integration/rag/vectordbs/analyticdb.md","tags":[],"version":"current","lastUpdatedBy":"Ken Liu","lastUpdatedAt":1768271906000,"frontMatter":{},"sidebar":"integrationSidebar","previous":{"title":"ZhiPuAI Embeddings","permalink":"/integration/rag/embeddings/more/zhipuai-embeddings"},"next":{"title":"Elasticsearch","permalink":"/integration/rag/vectordbs/elasticsearch"}}');var t=r(74848),s=r(28453);const c={},a="AnalyticDB",d={},l=[{value:"Prerequisites",id:"prerequisites",level:2},{value:"Auto-Configuration",id:"auto-configuration",level:2},{value:"Configuration properties",id:"analyticdb-properties",level:2},{value:"Metadata filtering",id:"metadata-filtering",level:2},{value:"Manual Configuration",id:"manual-configuration",level:2}];function o(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"analyticdb",children:"AnalyticDB"})}),"\n",(0,t.jsxs)(n.p,{children:["\u672c\u8282\u5c06\u6307\u5bfc\u60a8\u8bbe\u7f6e AnalyticDB ",(0,t.jsx)(n.code,{children:"VectorStore"})," \u6765\u5b58\u50a8\u6587\u6863\u5d4c\u5165\u5e76\u6267\u884c\u76f8\u4f3c\u6027\u641c\u7d22\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.a,{href:"https://www.aliyun.com/product/ads",children:"AnalyticDB"})," \u662f\u963f\u91cc\u4e91\u63d0\u4f9b\u7684\u4e91\u539f\u751f\u6570\u636e\u4ed3\u5e93\u670d\u52a1\uff0c\u652f\u6301\u5411\u91cf\u68c0\u7d22\u529f\u80fd\u3002AnalyticDB \u5411\u91cf\u6570\u636e\u5e93\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u5411\u91cf\u5b58\u50a8\u548c\u76f8\u4f3c\u6027\u641c\u7d22\u80fd\u529b\uff0c\u9002\u7528\u4e8e\u5927\u89c4\u6a21\u5411\u91cf\u6570\u636e\u7684\u5b58\u50a8\u548c\u68c0\u7d22\u573a\u666f\u3002"]}),"\n",(0,t.jsx)(n.h2,{id:"prerequisites",children:"Prerequisites"}),"\n",(0,t.jsx)(n.p,{children:"\u9996\u5148\uff0c\u60a8\u9700\u8981\uff1a"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:"\u4e00\u4e2a AnalyticDB \u5b9e\u4f8b\uff0c\u5e76\u5df2\u542f\u7528\u5411\u91cf\u6570\u636e\u5e93\u529f\u80fd"}),"\n",(0,t.jsx)(n.li,{children:"\u963f\u91cc\u4e91\u8bbf\u95ee\u51ed\u8bc1\uff08AccessKeyId \u548c AccessKeySecret\uff09"}),"\n",(0,t.jsx)(n.li,{children:"\u6570\u636e\u5e93\u5b9e\u4f8b ID\u3001\u533a\u57df ID\u3001\u7ba1\u7406\u8d26\u53f7\u548c\u5bc6\u7801"}),"\n",(0,t.jsx)(n.li,{children:"\u547d\u540d\u7a7a\u95f4\uff08Namespace\uff09\u548c\u547d\u540d\u7a7a\u95f4\u5bc6\u7801"}),"\n",(0,t.jsxs)(n.li,{children:["\u7528\u4e8e\u8ba1\u7b97\u6587\u6863\u5d4c\u5165\u7684 ",(0,t.jsx)(n.code,{children:"EmbeddingModel"})," \u5b9e\u4f8b\u3002\u6709\u591a\u4e2a\u9009\u9879\u53ef\u7528\uff1a","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["\u5982\u679c\u9700\u8981\uff0c\u4e3a ",(0,t.jsx)(n.a,{href:"../embeddings#available-implementations",children:"EmbeddingModel"})," \u63d0\u4f9b\u4e00\u4e2a API key\uff0c\u7528\u4e8e\u751f\u6210 ",(0,t.jsx)(n.code,{children:"AnalyticDbVectorStore"})," \u5b58\u50a8\u7684\u5d4c\u5165\u3002"]}),"\n"]}),"\n"]}),"\n"]}
1),"\n",(0,t.jsxs)(n.p,{children:["\u5728\u542f\u52a8\u65f6\uff0c",(0,t.jsx)(n.code,{children:"AnalyticDbVectorStore"})," \u4f1a\u81ea\u52a8\u521d\u59cb\u5316\u5411\u91cf\u6570\u636e\u5e93\u3001\u521b\u5efa\u547d\u540d\u7a7a\u95f4\uff08\u5982\u679c\u4e0d\u5b58\u5728\uff09\u548c\u96c6\u5408\uff08Collection\uff09\u3002"]}),"\n",(0,t.jsx)(n.h2,{id:"auto-configuration",children:"Auto-Configuration"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"\u6ce8\u610f\uff1a"}),"\nSpring AI auto-configuration\u3001starter modules \u7684 artifact \u540d\u79f0\u53d1\u751f\u4e86\u91cd\u5927\u53d8\u5316\u3002\n\u8bf7\u53c2\u9605 ",(0,t.jsx)(n.a,{href:"https://docs.spring.io/spring-ai/reference/upgrade-notes.html",children:"upgrade notes"})," \u4e86\u89e3\u66f4\u591a\u4fe1\u606f\u3002"]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"\u7136\u540e\u5c06 AnalyticDB VectorStore boot starter \u4f9d\u8d56\u9879\u6dfb\u52a0\u5230\u60a8\u7684\u9879\u76ee\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-xml",children:"<dependency>\n\t<groupId>com.alibaba.cloud.ai</groupId>\n\t<artifactId>spring-ai-alibaba-starter-store-analyticdb</artifactId>\n</dependency>\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u6216\u6dfb\u52a0\u5230\u60a8\u7684 Gradle ",(0,t.jsx)(n.code,{children:"build.gradle"})," \u6784\u5efa\u6587\u4ef6\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-groovy",children:"dependencies {\n    implementation 'com.alibaba.cloud.ai:spring-ai-alibaba-starter-store-analyticdb'\n}\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5411\u91cf\u5b58\u50a8\u5b9e\u73b0\u53ef\u4ee5\u4e3a\u60a8\u521d\u59cb\u5316\u6240\u9700\u7684 schema\uff0c\u4f46\u60a8\u5fc5\u987b\u901a\u8fc7\u5728 ",(0,t.jsx)(n.code,{children:"application.properties"})," \u6587\u4ef6\u4e2d\u8bbe\u7f6e ",(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.enabled=true"})," \u6765\u9009\u62e9\u52a0\u5165\u3002"]}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"\u6ce8\u610f\uff1a"})," \u8fd9\u662f\u4e00\u4e2a\u7834\u574f\u6027\u66f4\u6539\uff01\u5728 Spring AI \u7684\u65e9\u671f\u7248\u672c\u4e2d\uff0c\u6b64 schema \u521d\u59cb\u5316\u9ed8\u8ba4\u53d1\u751f\u3002"]}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["Vector Store \u8fd8\u9700\u8981\u4e00\u4e2a ",(0,t.jsx)(n.code,{children:"EmbeddingModel"})," \u5b9e\u4f8b\u6765\u8ba1\u7b97\u6587\u6863\u7684\u5d4c\u5165\u3002\n\u60a8\u53ef\u4ee5\u9009\u62e9\u4e00\u4e2a\u53ef\u7528\u7684 ",(0,t.jsx)(n.a,{href:"../embeddings#available-implementations",children:"EmbeddingModel \u5b9e\u73b0"}),"\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:["\u4f8b\u5982\uff0c\u8981\u4f7f\u7528 ",(0,t.jsx)(n.a,{href:"../embeddings/openai-embeddings",children:"OpenAI EmbeddingModel"}),"\uff0c\u8bf7\u5c06\u4ee5\u4e0b\u4f9d\u8d56\u9879\u6dfb\u52a0\u5230\u60a8\u7684\u9879\u76ee\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-xml",children:"<dependency>\n\t<groupId>org.springframework.ai</groupId>\n\t<artifactId>spring-ai-starter-model-openai</artifactId>\n</dependency>\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u6216\u6dfb\u52a0\u5230\u60a8\u7684 Gradle ",(0,t.jsx)(n.code,{children:"build.gradle"})," \u6784\u5efa\u6587\u4ef6\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-groovy",children:"dependencies {\n    implementation 'org.springframework.ai:spring-ai-starter-model-openai'\n}\n"})}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"\u63d0\u793a\uff1a"})," \u8bf7\u53c2\u9605 ",(0,t.jsx)(n.a,{href:"https://docs.spring.io/spring-ai/reference/getting-started.html#dependency-management",children:"Dependency Management"})," \u90e8\u5206\uff0c\u5c06 Spring AI BOM \u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u6587\u4ef6\u4e2d\u3002\n\u8bf7\u53c2\u9605 ",(0,t.jsx)(n.a,{href:"https://docs.spring.io/spring-ai/reference/getting-started.html#artifact-repositories",children:"Artifact Repositories"})," \u90e8\u5206\uff0c\u5c06 Maven Central \u548c/\u6216 Snapshot Repositories \u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u6587\u4ef6\u4e2d\u3002"]}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["\u8981\u8fde\u63a5\u548c\u914d\u7f6e ",(0,t.jsx)(n.code,{children:"AnalyticDbVectorStore"}),"\uff0c\u60a8\u9700\u8981\u63d0\u4f9b\u5b9e\u4f8b\u7684\u8bbf\u95ee\u8be6\u7ec6\u4fe1\u606f\u3002\n\u53ef\u4ee5\u901a\u8fc7 Spring Boot \u7684 ",(0,t.jsx)(n.code,{children:"application.yml"})," \u63d0\u4f9b\u7b80\u5355\u914d\u7f6e\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"spring:\n  ai:\n    vectorstore:\n      analytic:\n        enabled: true\n        collect-name: my_collection\n        access-key-id: <your-access-key-id>\n        access-key-secret: <your-access-key-secret>\n        region-id: cn-hangzhou\n        db-instance-id: <your-db-instance-id>\n        manager-account: <your-manager-account>\n        manager-account-password: <your-manager-account-password>\n        namespace: <your-namespace>\n        namespace-password: <your-namespace-password>\n        metrics: cosine\n        read-timeout: 60000\n        user-agent: index\n        default-top-k: 4\n        default-similarity-threshold: 0.0\n"})}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"\u63d0\u793a\uff1a"}
1)," \u67e5\u770b ",(0,t.jsx)(n.a,{href:"#analyticdb-properties",children:"configuration parameters"})," \u5217\u8868\u4ee5\u4e86\u89e3\u9ed8\u8ba4\u503c\u548c\u914d\u7f6e\u9009\u9879\u3002"]}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["\u73b0\u5728\u60a8\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u81ea\u52a8\u88c5\u914d ",(0,t.jsx)(n.code,{children:"VectorStore"})," \u5e76\u4f7f\u7528\u5b83"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:'@Autowired VectorStore vectorStore;\n\n// ...\n\nList<Document> documents = List.of(\n    new Document("Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!!", Map.of("meta1", "meta1")),\n    new Document("The World is Big and Salvation Lurks Around the Corner"),\n    new Document("You walk forward facing the past and you turn back toward the future.", Map.of("meta2", "meta2")));\n\n// \u5c06\u6587\u6863\u6dfb\u52a0\u5230 AnalyticDB\nvectorStore.add(documents);\n\n// \u68c0\u7d22\u4e0e\u67e5\u8be2\u76f8\u4f3c\u7684\u6587\u6863\nList<Document> results = this.vectorStore.similaritySearch(SearchRequest.builder().query("Spring").topK(5).build());\n'})}),"\n",(0,t.jsx)(n.h2,{id:"analyticdb-properties",children:"Configuration properties"}),"\n",(0,t.jsx)(n.p,{children:"\u60a8\u53ef\u4ee5\u5728 Spring Boot \u914d\u7f6e\u4e2d\u4f7f\u7528\u4ee5\u4e0b\u5c5e\u6027\u6765\u81ea\u5b9a\u4e49 AnalyticDB \u5411\u91cf\u5b58\u50a8\u3002"}),"\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{children:"Property"}),(0,t.jsx)(n.th,{children:"Description"}),(0,t.jsx)(n.th,{children:"Default value"})]})}),(0,t.jsxs)(n.tbody,{children:[(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.enabled"})}),(0,t.jsx)(n.td,{children:"\u662f\u5426\u542f\u7528 AnalyticDB \u5411\u91cf\u5b58\u50a8"}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"true"})})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.collect-name"})}),(0,t.jsx)(n.td,{children:"\u96c6\u5408\uff08Collection\uff09\u540d\u79f0"}),(0,t.jsx)(n.td,{children:"-"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.access-key-id"})}),(0,t.jsx)(n.td,{children:"\u963f\u91cc\u4e91\u8bbf\u95ee\u5bc6\u94a5 ID"}),(0,t.jsx)(n.td,{children:"-"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.access-key-secret"})}),(0,t.jsx)(n.td,{children:"\u963f\u91cc\u4e91\u8bbf\u95ee\u5bc6\u94a5 Secret"}),(0,t.jsx)(n.td,{children:"-"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.region-id"})}),(0,t.jsx)(n.td,{children:"\u533a\u57df ID"}),(0,t.jsx)(n.td,{children:"-"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.db-instance-id"})}),(0,t.jsx)(n.td,{children:"\u6570\u636e\u5e93\u5b9e\u4f8b ID"}),(0,t.jsx)(n.td,{children:"-"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.manager-account"})}),(0,t.jsx)(n.td,{children:"\u7ba1\u7406\u8d26\u53f7"}),(0,t.jsx)(n.td,{children:"-"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.manager-account-password"})}),(0,t.jsx)(n.td,{children:"\u7ba1\u7406\u8d26\u53f7\u5bc6\u7801"}),(0,t.jsx)(n.td,{children:"-"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.namespace"})}),(0,t.jsx)(n.td,{children:"\u547d\u540d\u7a7a\u95f4"}),(0,t.jsx)(n.td,{children:"-"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.namespace-password"})}),(0,t.jsx)(n.td,{children:"\u547d\u540d\u7a7a\u95f4\u5bc6\u7801"}),(0,t.jsx)(n.td,{children:"-"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.metrics"})}),(0,t.jsx)(n.td,{children:"\u76f8\u4f3c\u5ea6\u5ea6\u91cf\u65b9\u5f0f\uff08cosine\u3001l2 \u7b49\uff09"}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"cosine"})})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.read-timeout"})}),(0,t.jsx)(n.td,{children:"\u8bfb\u53d6\u8d85\u65f6\u65f6\u95f4\uff08\u6beb\u79d2\uff09"}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"60000"})})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.user-agent"})}
1),(0,t.jsx)(n.td,{children:"\u7528\u6237\u4ee3\u7406"}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"index"})})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.default-top-k"})}),(0,t.jsx)(n.td,{children:"\u9ed8\u8ba4\u8fd4\u56de\u7684\u76f8\u4f3c\u6587\u6863\u6570\u91cf"}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"4"})})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"spring.ai.vectorstore.analytic.default-similarity-threshold"})}),(0,t.jsx)(n.td,{children:"\u9ed8\u8ba4\u76f8\u4f3c\u5ea6\u9608\u503c"}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"0.0"})})]})]})]}),"\n",(0,t.jsx)(n.h2,{id:"metadata-filtering",children:"Metadata filtering"}),"\n",(0,t.jsxs)(n.p,{children:["\u60a8\u53ef\u4ee5\u5c06\u901a\u7528\u7684\u3001\u53ef\u79fb\u690d\u7684 ",(0,t.jsx)(n.a,{href:"https://docs.spring.io/spring-ai/reference/api/vectordbs.html#_metadata_filters",children:"metadata filters"})," \u4e0e AnalyticDB \u5b58\u50a8\u4e00\u8d77\u4f7f\u7528\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u6587\u672c\u8868\u8fbe\u5f0f\u8bed\u8a00\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:"vectorStore.similaritySearch(\n    SearchRequest.builder()\n    .query(\"The World\")\n    .topK(TOP_K)\n    .similarityThreshold(SIMILARITY_THRESHOLD)\n    .filterExpression(\"author in ['john', 'jill'] && article_type == 'blog'\").build());\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u6216\u4f7f\u7528 ",(0,t.jsx)(n.code,{children:"Filter.Expression"})," DSL \u4ee5\u7f16\u7a0b\u65b9\u5f0f\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:'FilterExpressionBuilder b = new FilterExpressionBuilder();\n\nvectorStore.similaritySearch(SearchRequest.builder()\n    .query("The World")\n    .topK(TOP_K)\n    .similarityThreshold(SIMILARITY_THRESHOLD)\n    .filterExpression(b.and(\n        b.in("author","john", "jill"),\n        b.eq("article_type", "blog")).build()).build());\n'})}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"\u6ce8\u610f\uff1a"})," \u8fd9\u4e9b\u8fc7\u6ee4\u5668\u8868\u8fbe\u5f0f\u88ab\u8f6c\u6362\u4e3a AnalyticDB \u7684 JSON \u8def\u5f84\u8868\u8fbe\u5f0f\uff0c\u4ee5\u5b9e\u73b0\u9ad8\u6548\u7684\u5143\u6570\u636e\u8fc7\u6ee4\u3002"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"manual-configuration",children:"Manual Configuration"}),"\n",(0,t.jsxs)(n.p,{children:["\u4e0d\u4f7f\u7528 Spring Boot auto-configuration\uff0c\u60a8\u53ef\u4ee5\u624b\u52a8\u914d\u7f6e ",(0,t.jsx)(n.code,{children:"AnalyticDbVectorStore"}),"\u3002\n\u4e3a\u6b64\uff0c\u60a8\u9700\u8981\u5c06 AnalyticDB \u5ba2\u6237\u7aef\u4f9d\u8d56\u9879\u6dfb\u52a0\u5230\u60a8\u7684\u9879\u76ee\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-xml",children:"<dependency>\n\t<groupId>com.aliyun</groupId>\n\t<artifactId>gpdb20160503</artifactId>\n\t<version>3.0.0</version>\n</dependency>\n\n<dependency>\n\t<groupId>com.alibaba.cloud.ai</groupId>\n\t<artifactId>spring-ai-alibaba-starter-store-analyticdb</artifactId>\n</dependency>\n"})}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"\u63d0\u793a\uff1a"})," \u8bf7\u53c2\u9605 ",(0,t.jsx)(n.a,{href:"https://docs.spring.io/spring-ai/reference/getting-started.html#dependency-management",children:"Dependency Management"})," \u90e8\u5206\uff0c\u5c06 Spring AI BOM \u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u6587\u4ef6\u4e2d\u3002"]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"\u8981\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u914d\u7f6e AnalyticDB\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bbe\u7f6e\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:'@Bean\npublic Client analyticdbClient() throws Exception {\n    Map<String, Object> params = new HashMap<>();\n    params.put("accessKeyId", "<your-access-key-id>");\n    params.put("accessKeySecret", "<your-access-key-secret>");\n    params.put("regionId", "cn-hangzhou");\n    params.put("readTimeout", 60000);\n    params.put("userAgent", "index");\n    Config clientConfig = Config.build(params);\n    return new Client(clientConfig);\n}\n\n@Bean\npublic VectorStore vectorStore(Client client, EmbeddingModel embeddingModel) {\n    AnalyticDbConfig config = new AnalyticDbConfig()\n        .setAccessKeyId("<your-access-key-id>")\n        .setAccessKeySecret("<your-access-key-secret>")\n        .setRegionId("cn-hangzhou")\n        .setDbInstanceId("<your-db-instance-id>")\n        .setManagerAccount("<your-manager-account>")\n        .setManagerAccountPassword("<your-manager-account-password>")\n        .setNamespace("<your-namespace>")\n        .setNamespacePassword("<your-namespace-password>")\n        .setMetrics("cosine")\n        .setReadTimeout(60000)\n        .setUserAgent("index");\n    \n    return AnalyticDbVectorStore.builder("my_collection", config, client, embeddingModel)\n        .defaultTopK(4)                    // \u53ef\u9009\uff1a\u9ed8\u8ba4\u4e3a 4\n        .defaultSimilarityThreshold(0.0)    // \u53ef\u9009\uff1a\u9ed8\u8ba4\u4e3a 0.0\n        .batchingStrategy(new TokenCountBatchingStrategy()) // \u53ef\u9009\uff1a\u9ed8\u8ba4\u4e3a TokenCountBatchingStrategy\n        .build();\n}\n'})})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.