1"use strict";(self.webpackChunkspring_ai_alibaba_website=self.webpackChunkspring_ai_alibaba_website||[]).push([[3038],{28453:(e,n,r)=>{r.d(n,{R:()=>t,x:()=>c});var i=r(96540);const s={},d=i.createContext(s);function t(e){const n=i.useContext(d);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:t(e.components),i.createElement(d.Provider,{value:n},e.children)}},95084:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>c,default:()=>h,frontMatter:()=>t,metadata:()=>i,toc:()=>a});const i=JSON.parse('{"id":"rag/vectordbs/redis","title":"Redis","description":"\u672c\u8282\u5c06\u6307\u5bfc\u60a8\u8bbe\u7f6e RedisVectorStore \u6765\u5b58\u50a8\u6587\u6863\u5d4c\u5165\u5e76\u6267\u884c\u76f8\u4f3c\u6027\u641c\u7d22\u3002","source":"@site/integration/rag/vectordbs/redis.md","sourceDirName":"rag/vectordbs","slug":"/rag/vectordbs/redis","permalink":"/integration/rag/vectordbs/redis","draft":false,"unlisted":false,"editUrl":"https://github.com/spring-ai-alibaba/website/tree/main/integration/rag/vectordbs/redis.md","tags":[],"version":"current","lastUpdatedBy":"Ken Liu","lastUpdatedAt":1768271906000,"frontMatter":{},"sidebar":"integrationSidebar","previous":{"title":"PGvector","permalink":"/integration/rag/vectordbs/pgvector"},"next":{"title":"Tair","permalink":"/integration/rag/vectordbs/tair"}}');var s=r(74848),d=r(28453);const t={},c="Redis",o={},a=[{value:"Prerequisites",id:"prerequisites",level:2},{value:"Auto-configuration",id:"auto-configuration",level:2},{value:"Configuration Properties",id:"redisvector-properties",level:2},{value:"Metadata Filtering",id:"metadata-filtering",level:2},{value:"Manual Configuration",id:"manual-configuration",level:2},{value:"Accessing the Native Client",id:"accessing-the-native-client",level:2}];function l(e){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",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,d.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"redis",children:"Redis"})}),"\n",(0,s.jsxs)(n.p,{children:["\u672c\u8282\u5c06\u6307\u5bfc\u60a8\u8bbe\u7f6e ",(0,s.jsx)(n.code,{children:"RedisVectorStore"})," \u6765\u5b58\u50a8\u6587\u6863\u5d4c\u5165\u5e76\u6267\u884c\u76f8\u4f3c\u6027\u641c\u7d22\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"https://redis.io",children:"Redis"})," \u662f\u4e00\u4e2a\u5f00\u6e90\uff08BSD \u8bb8\u53ef\uff09\u7684\u5185\u5b58\u6570\u636e\u7ed3\u6784\u5b58\u50a8\uff0c\u7528\u4f5c\u6570\u636e\u5e93\u3001\u7f13\u5b58\u3001\u6d88\u606f\u4ee3\u7406\u548c\u6d41\u5f15\u64ce\u3002Redis \u63d0\u4f9b\u5b57\u7b26\u4e32\u3001\u54c8\u5e0c\u3001\u5217\u8868\u3001\u96c6\u5408\u3001\u5e26\u8303\u56f4\u67e5\u8be2\u7684\u6709\u5e8f\u96c6\u5408\u3001\u4f4d\u56fe\u3001\u8d85\u5bf9\u6570\u3001\u5730\u7406\u7a7a\u95f4\u7d22\u5f15\u548c\u6d41\u7b49\u6570\u636e\u7ed3\u6784\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"https://redis.io/docs/interact/search-and-query/",children:"Redis Search and Query"})," \u6269\u5c55\u4e86 Redis OSS \u7684\u6838\u5fc3\u529f\u80fd\uff0c\u5141\u8bb8\u60a8\u5c06 Redis \u7528\u4f5c\u5411\u91cf\u6570\u636e\u5e93\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u5728\u54c8\u5e0c\u6216 JSON \u6587\u6863\u4e2d\u5b58\u50a8\u5411\u91cf\u548c\u5173\u8054\u7684\u5143\u6570\u636e"}),"\n",(0,s.jsx)(n.li,{children:"\u68c0\u7d22\u5411\u91cf"}),"\n",(0,s.jsx)(n.li,{children:"\u6267\u884c\u5411\u91cf\u641c\u7d22"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"prerequisites",children:"Prerequisites"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"Redis Stack \u5b9e\u4f8b"}),"\n"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"https://app.redislabs.com/#/",children:"Redis Cloud"}),"\uff08\u63a8\u8350\uff09"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"https://hub.docker.com/r/redis/redis-stack",children:"Docker"})," \u955c\u50cf ",(0,s.jsx)(n.em,{children:"redis/redis-stack:latest"})]}),"\n"]}),"\n",(0,s.jsxs)(n.ol,{start:"2",children:["\n",(0,s.jsxs)(n.li,{children:["\u7528\u4e8e\u8ba1\u7b97\u6587\u6863\u5d4c\u5165\u7684 ",(0,s.jsx)(n.code,{children:"EmbeddingModel"})," \u5b9e\u4f8b\u3002\u6709\u591a\u4e2a\u9009\u9879\u53ef\u7528\uff1a"]}),"\n"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5982\u679c\u9700\u8981\uff0c\u4e3a ",(0,s.jsx)(n.a,{href:"../embeddings#available-implementations",children:"EmbeddingModel"})," \u63d0\u4f9b\u4e00\u4e2a API key\uff0c\u7528\u4e8e\u751f\u6210 ",(0,s.jsx)(n.code,{children:"RedisVectorStore"})," \u5b58\u50a8\u7684\u5d4c\u5165\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"auto-configuration",children:"Auto-configuration"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.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,s.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,s.jsxs)(n.p,{children:["Spring AI \u4e3a Redis Vector Store \u63d0\u4f9b Spring Boot auto-configuration\u3002\n\u8981\u542f\u7528\u5b83\uff0c\u8bf7\u5c06\u4ee5\u4e0b\u4f9d\u8d56\u9879\u6dfb\u52a0\u5230\u60a8\u9879\u76ee\u7684 Maven ",(0,s.jsx)(n.code,{children:"pom.xml"})," \u6587\u4ef6\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-xml",children:"<dependency>\n <groupId>org.springframework.ai</groupId>\n <artifactId>spring-ai-starter-vector-store-redis</artifactId>\n</dependency>\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u6216\u6dfb\u52a0\u5230\u60a8\u7684 Gradle ",(0,s.jsx)(n.code,{children:"build.gradle"})," \u6784\u5efa\u6587\u4ef6\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-groovy",children:"dependencies {\n implementation 'org.springframework.ai:spring-ai-starter-vector-store-redis'\
1n}\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u63d0\u793a\uff1a"})," \u8bf7\u53c2\u9605 ",(0,s.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,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u63d0\u793a\uff1a"})," \u8bf7\u53c2\u9605 ",(0,s.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,s.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\u9002\u5f53\u7684\u6784\u9020\u51fd\u6570\u4e2d\u6307\u5b9a ",(0,s.jsx)(n.code,{children:"initializeSchema"})," \u5e03\u5c14\u503c\u6216\u5728 ",(0,s.jsx)(n.code,{children:"application.properties"})," \u6587\u4ef6\u4e2d\u8bbe\u7f6e ",(0,s.jsx)(n.code,{children:"...initialize-schema=true"})," \u6765\u9009\u62e9\u52a0\u5165\u3002"]}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.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"]}
1),"\n",(0,s.jsxs)(n.p,{children:["\u8bf7\u67e5\u770b ",(0,s.jsx)(n.a,{href:"#redisvector-properties",children:"configuration parameters"})," \u5217\u8868\u4ee5\u4e86\u89e3\u5411\u91cf\u5b58\u50a8\u7684\u9ed8\u8ba4\u503c\u548c\u914d\u7f6e\u9009\u9879\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u6b64\u5916\uff0c\u60a8\u9700\u8981\u4e00\u4e2a\u914d\u7f6e\u7684 ",(0,s.jsx)(n.code,{children:"EmbeddingModel"})," bean\u3002\u8bf7\u53c2\u9605 ",(0,s.jsx)(n.a,{href:"../embeddings#available-implementations",children:"EmbeddingModel"})," \u90e8\u5206\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u73b0\u5728\u60a8\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u81ea\u52a8\u88c5\u914d ",(0,s.jsx)(n.code,{children:"RedisVectorStore"})," \u4f5c\u4e3a\u5411\u91cf\u5b58\u50a8\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.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 Redis\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,s.jsx)(n.h2,{id:"redisvector-properties",children:"Configuration Properties"}),"\n",(0,s.jsxs)(n.p,{children:["\u8981\u8fde\u63a5\u5230 Redis \u5e76\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"RedisVectorStore"}),"\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,s.jsx)(n.code,{children:"application.yml"})," \u63d0\u4f9b\u7b80\u5355\u914d\u7f6e\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-yaml",children:"spring:\n data:\n redis:\n url: <redis instance url>\n ai:\n vectorstore:\n redis:\n initialize-schema: true\n index-name: custom-index\n prefix: custom-prefix\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5bf9\u4e8e redis \u8fde\u63a5\u914d\u7f6e\uff0c\u6216\u8005\uff0c\u53ef\u4ee5\u901a\u8fc7 Spring Boot \u7684 ",(0,s.jsx)(n.em,{children:"application.properties"})," \u63d0\u4f9b\u7b80\u5355\u914d\u7f6e\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-properties",children:"spring.data.redis.host=localhost\nspring.data.redis.port=6379\nspring.data.redis.username=default\nspring.data.redis.password=\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u4ee5 ",(0,s.jsx)(n.code,{children:"spring.ai.vectorstore.redis.*"})," \u5f00\u5934\u7684\u5c5e\u6027\u7528\u4e8e\u914d\u7f6e ",(0,s.jsx)(n.code,{children:"RedisVectorStore"}),"\uff1a"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Property"}),(0,s.jsx)(n.th,{children:"Description"}),(0,s.jsx)(n.th,{children:"Default Value"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"spring.ai.vectorstore.redis.initialize-schema"})}),(0,s.jsx)(n.td,{children:"\u662f\u5426\u521d\u59cb\u5316\u6240\u9700\u7684 schema"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"false"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"spring.ai.vectorstore.redis.index-name"})}),(0,s.jsx)(n.td,{children:"\u5b58\u50a8\u5411\u91cf\u7684\u7d22\u5f15\u540d\u79f0"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"spring-ai-index"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"spring.ai.vectorstore.redis.prefix"})}),(0,s.jsx)(n.td,{children:"Redis \u952e\u7684\u524d\u7f00"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"embedding:"})})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"metadata-filtering",children:"Metadata Filtering"}),"\n",(0,s.jsxs)(n.p,{children:["\u60a8\u53ef\u4ee5\u5c06\u901a\u7528\u7684\u3001\u53ef\u79fb\u
1690d\u7684 ",(0,s.jsx)(n.a,{href:"https://docs.spring.io/spring-ai/reference/api/vectordbs.html#_metadata_filters",children:"metadata filters"})," \u4e0e Redis \u4e00\u8d77\u4f7f\u7528\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u6587\u672c\u8868\u8fbe\u5f0f\u8bed\u8a00\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"vectorStore.similaritySearch(SearchRequest.builder()\n .query(\"The World\")\n .topK(TOP_K)\n .similarityThreshold(SIMILARITY_THRESHOLD)\n .filterExpression(\"country in ['UK', 'NL'] && year >= 2020\").build());\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u6216\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"Filter.Expression"})," DSL \u4ee5\u7f16\u7a0b\u65b9\u5f0f\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.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("country", "UK", "NL"),\n b.gte("year", 2020)).build()).build());\n'})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u6ce8\u610f\uff1a"})," \u8fd9\u4e9b\uff08\u53ef\u79fb\u690d\u7684\uff09\u8fc7\u6ee4\u5668\u8868\u8fbe\u5f0f\u4f1a\u81ea\u52a8\u8f6c\u6362\u4e3a ",(0,s.jsx)(n.a,{href:"https://redis.io/docs/interact/search-and-query/query/",children:"Redis search queries"}),"\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u4f8b\u5982\uff0c\u8fd9\u4e2a\u53ef\u79fb\u690d\u7684\u8fc7\u6ee4\u5668\u8868\u8fbe\u5f0f\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sql",children:"country in ['UK', 'NL'] && year >= 2020\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u8f6c\u6362\u4e3a\u4e13\u6709\u7684 Redis \u8fc7\u6ee4\u5668\u683c\u5f0f\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"@country:{UK | NL} @year:[2020 inf]\n"})}),"\n",(0,s.jsx)(n.h2,{id:"manual-configuration",children:"Manual Configuration"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0d\u4f7f\u7528 Spring Boot auto-configuration\uff0c\u60a8\u53ef\u4ee5\u624b\u52a8\u914d\u7f6e Redis \u5411\u91cf\u5b58\u50a8\u3002\u4e3a\u6b64\uff0c\u60a8\u9700\u8981\u5c06 ",(0,s.jsx)(n.code,{children:"spring-ai-redis-store"})," \u6dfb\u52a0\u5230\u60a8\u7684\u9879\u76ee\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-xml",children:"<dependency>\n <groupId>org.springframework.ai</groupId>\n <artifactId>spring-ai-redis-store</artifactId>\n</dependency>\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u6216\u6dfb\u52a0\u5230\u60a8\u7684 Gradle ",(0,s.jsx)(n.code,{children:"build.gradle"})," \u6784\u5efa\u6587\u4ef6\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-groovy",children:"dependencies {\n implementation 'org.springframework.ai:spring-ai-redis-store'\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u521b\u5efa ",(0,s.jsx)(n.code,{children:"JedisPooled"})," bean\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'@Bean\npublic JedisPooled jedisPooled() {\n return new JedisPooled("<host>", 6379);\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u7136\u540e\u4f7f\u7528\u6784\u5efa\u5668\u6a21\u5f0f\u521b\u5efa ",(0,s.jsx)(n.code,{children:"RedisVectorStore"})," bean\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'@Bean\npublic VectorStore vectorStore(JedisPooled jedisPooled, EmbeddingModel embeddingModel) {\n return RedisVectorStore.builder(jedisPooled, embeddingModel)\n .indexName("custom-index") // \u53ef\u9009\uff1a\u9ed8\u8ba4\u4e3a "spring-ai-index"\n .prefix("custom-prefix") // \u53ef\u9009\uff1a\u9ed8\u8ba4\u4e3a "embedding:"\n .metadataFields( // \u53ef\u9009\uff1a\u5b9a\u4e49\u7528\u4e8e\u8fc7\u6ee4\u7684\u5143\u6570\u636e\u5b57\u6bb5\n MetadataField.tag("country"),\n MetadataField.numeric("year"))\n .initializeSchema(true) // \u53ef\u9009\uff1a\u9ed8\u8ba4\u4e3a false\n .batchingStrategy(new TokenCountBatchingStrategy()) // \u53ef\u9009\uff1a\u9ed8\u8ba4\u4e3a TokenCountBatchingStrategy\n .build();\n}\n\n// \u8fd9\u53ef\u4ee5\u662f\u4efb\u4f55 EmbeddingModel \u5b9e\u73b0\n@Bean\npublic EmbeddingModel embeddingModel() {\n return new OpenAiEmbeddingModel(new OpenAiApi(System.getenv("OPENAI_API_KEY")));\n}\n'})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u6ce8\u610f\uff1a"}),"\n\u60a8\u5fc5\u987b\u660e\u786e\u5217\u51fa\u8fc7\u6ee4\u5668\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u7684\u4efb\u4f55\u5143\u6570\u636e\u5b57\u6bb5\u7684\u6240\u6709\u5143\u6570\u636e\u5b57\u6bb5\u540d\u79f0\u548c\u7c7b\u578b\uff08",(0,s.jsx)(n.code,{children:"TAG"}),"\u3001",(0,s.jsx)(n.code,{children:"TEXT"})," \u6216 ",(0,s.jsx)(n.code,{children:"NUMERIC"}),"\uff09\u3002\n\u4e0a\u9762\u7684 ",(0,s.jsx)(n.code,{children:"metadataFields"})," \u6ce8\u518c\u4e86\u53ef\u8fc7\u6ee4\u7684\u5143\u6570\u636e\u5b57\u6bb5\uff1a\u7c7b\u578b\u4e3a ",(0,s.jsx)(n.code,{children:"TAG"})," \u7684 ",(0,s.jsx)(n.code,{children:"country"}),"\uff0c\u7c7b\u578b\u4e3a ",(0,s.jsx)(n.code,{children:"NUMERIC"})," \u7684 ",(0,s.jsx)(n.code,{children:"year"}),"\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"accessing-the-native-client",children:"Accessing the Native Client"}),"\n",(0,s.jsxs)(n.p,{children:["Redis Vector Store \u5b9e\u73b0\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"getNativeClient()"})," \u65b9\u6cd5\u63d0\u4f9b\u5bf9\u5e95\u5c42\u539f\u751f Redis \u5ba2\u6237\u7aef\uff08",(0,s.jsx)(n.code,{children:"JedisPooled"}),"\uff09\u7684\u8bbf\u95ee\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"RedisVectorStore vectorStore = context.getBean(RedisVectorStore.class);\nOptional<JedisPooled> nativeClient = vectorStore.getNativeClient();\n\nif (nativeClient.isPresent()) {\n JedisPooled jedis = nativeClient.get();\n // \u4f7f\u7528\u539f\u751f\u5ba2\u6237\u7aef\u8fdb\u884c Redis \u7279\u5b9a\u64cd\u4f5c\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u539f\u751f\u5ba2\u6237\u7aef\u4f7f\u60a8\u53ef\u4ee5\u8bbf\u95ee\u53ef\u80fd\u672a\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"VectorStore"})," \u63a5\u53e3\u516c\u5f00\u7684 Redis \u7279\u5b9a\u529f\u80fd\u548c\u64cd\u4f5c\u3002"]})]})}function h(e={}){const{wrapper:n}={...(0,d.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(l,{...e})}):l(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.