Copy
---
title: Baidu Cloud ElasticSearch VectorSearch
---
>[Baidu Cloud VectorSearch](https://cloud.baidu.com/doc/BES/index.html?from=productToDoc)는 오픈 소스와 100% 호환되는 완전 관리형 엔터프라이즈급 분산 검색 및 분석 서비스입니다. Baidu Cloud VectorSearch는 구조화/비구조화 데이터를 위한 저비용, 고성능, 안정적인 검색 및 분석 플랫폼 수준의 제품 서비스를 제공합니다. vector database로서 다양한 index 유형과 유사도 거리 측정 방법을 지원합니다.
>`Baidu Cloud ElasticSearch`는 권한 관리 메커니즘을 제공하여 cluster 권한을 자유롭게 구성할 수 있으므로 데이터 보안을 더욱 강화할 수 있습니다.
이 notebook은 `Baidu Cloud ElasticSearch VectorStore`와 관련된 기능을 사용하는 방법을 보여줍니다.
실행하려면 [Baidu Cloud ElasticSearch](https://cloud.baidu.com/product/bes.html) instance가 실행 중이어야 합니다:
[도움말 문서](https://cloud.baidu.com/doc/BES/s/8llyn0hh4)를 읽고 Baidu Cloud ElasticSearch instance를 빠르게 익히고 구성하세요.
instance가 실행되면 다음 단계에 따라 문서를 분할하고, embedding을 가져오고, baidu cloud elasticsearch instance에 연결하고, 문서를 indexing하고, vector 검색을 수행합니다.
먼저 다음 Python package를 설치해야 합니다.
```python
pip install -qU langchain-community elasticsearch == 7.11.0
QianfanEmbeddings를 사용하려면 Qianfan AK와 SK를 가져와야 합니다. QianFan에 대한 자세한 내용은 Baidu Qianfan Workshop을 참조하세요.
Copy
import getpass
import os
if "QIANFAN_AK" not in os.environ:
os.environ["QIANFAN_AK"] = getpass.getpass("Your Qianfan AK:")
if "QIANFAN_SK" not in os.environ:
os.environ["QIANFAN_SK"] = getpass.getpass("Your Qianfan SK:")
Copy
from langchain_community.document_loaders import TextLoader
from langchain_text_splitters import CharacterTextSplitter
loader = TextLoader("../../../state_of_the_union.txt")
documents = loader.load()
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
docs = text_splitter.split_documents(documents)
from langchain_community.embeddings import QianfanEmbeddingsEndpoint
embeddings = QianfanEmbeddingsEndpoint()
Copy
# Create a bes instance and index docs.
from langchain_community.vectorstores import BESVectorStore
bes = BESVectorStore.from_documents(
documents=docs,
embedding=embeddings,
bes_url="your bes cluster url",
index_name="your vector index",
)
bes.client.indices.refresh(index="your vector index")
Copy
query = "What did the president say about Ketanji Brown Jackson"
docs = bes.similarity_search(query)
print(docs[0].page_content)
Copy
---
<Callout icon="pen-to-square" iconType="regular">
[Edit the source of this page on GitHub.](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/vectorstores/baiducloud_vector_search.mdx)
</Callout>
<Tip icon="terminal" iconType="regular">
[Connect these docs programmatically](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
</Tip>