---
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을 참조하세요.
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:")
둘째, 문서를 분할하고 embedding을 가져옵니다.
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()
그런 다음 Baidu ElasticeSearch 접근 가능한 instance를 생성합니다.
# 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")
마지막으로 데이터를 쿼리하고 검색합니다.
query = "What did the president say about Ketanji Brown Jackson"
docs = bes.similarity_search(query)
print(docs[0].page_content)
사용 중 문제가 발생하면 언제든지 [email protected] 또는 [email protected]으로 연락 주시면 최선을 다해 지원하겠습니다.

---

<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>
I