Check this for more details.Installation‚ÄãInstall the Python client.pip install opensearch-pyWe want to use OpenAIEmbeddings so we have to get the OpenAI API Key.import osimport getpassos.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI API Key:")from langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.text_splitter import CharacterTextSplitterfrom langchain.vectorstores import OpenSearchVectorSearchfrom langchain.document_loaders import TextLoaderfrom langchain.document_loaders import TextLoaderloader = TextLoader("../../modules/state_of_the_union.txt")documents = loader.load()text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)docs = text_splitter.split_documents(documents)embeddings = OpenAIEmbeddings()similarity_search using Approximate k-NN‚Äãsimilarity_search using Approximate k-NN Search with Custom Parametersdocsearch = OpenSearchVectorSearch.from_documents(    docs, embeddings, opensearch_url="http://localhost:9200")# If using the default Docker installation, use this instantiation instead:# docsearch = OpenSearchVectorSearch.from_documents(#     docs,#     embeddings,#     opensearch_url="https://localhost:9200",#     http_auth=("admin", "admin"),#     use_ssl = False,#     verify_certs = False,#     ssl_assert_hostname = False,#     ssl_show_warn = False,# )query = "What did the president say about Ketanji Brown Jackson"docs = docsearch.similarity_search(query, k=10)print(docs[0].page_content)docsearch = OpenSearchVectorSearch.from_documents(    docs,    embeddings,    opensearch_url="http://localhost:9200",    engine="faiss",    space_type="innerproduct",    ef_construction=256,    m=48,)query = "What did the president say about Ketanji Brown Jackson"docs = docsearch.similarity_search(query)print(docs[0].page_content)similarity_search using Script Scoring‚Äãsimilarity_search using Script Scoring with Custom Parametersdocsearch = OpenSearchVectorSearch.from_documents(    docs, embeddings,
OpenSearch is a scalable, flexible, and extensible open-source software suite for search, analytics, and observability applications licensed under Apache 2.0. OpenSearch is a distributed search and analytics engine based on Apache Lucene.
OpenSearch is a scalable, flexible, and extensible open-source software suite for search, analytics, and observability applications licensed under Apache 2.0. OpenSearch is a distributed search and analytics engine based on Apache Lucene. ->: Check this for more details.Installation‚ÄãInstall the Python client.pip install opensearch-pyWe want to use OpenAIEmbeddings so we have to get the OpenAI API Key.import osimport getpassos.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI API Key:")from langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.text_splitter import CharacterTextSplitterfrom langchain.vectorstores import OpenSearchVectorSearchfrom langchain.document_loaders import TextLoaderfrom langchain.document_loaders import TextLoaderloader = TextLoader("../../modules/state_of_the_union.txt")documents = loader.load()text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)docs = text_splitter.split_documents(documents)embeddings = OpenAIEmbeddings()similarity_search using Approximate k-NN‚Äãsimilarity_search using Approximate k-NN Search with Custom Parametersdocsearch = OpenSearchVectorSearch.from_documents(    docs, embeddings, opensearch_url="http://localhost:9200")# If using the default Docker installation, use this instantiation instead:# docsearch = OpenSearchVectorSearch.from_documents(#     docs,#     embeddings,#     opensearch_url="https://localhost:9200",#     http_auth=("admin", "admin"),#     use_ssl = False,#     verify_certs = False,#     ssl_assert_hostname = False,#     ssl_show_warn = False,# )query = "What did the president say about Ketanji Brown Jackson"docs = docsearch.similarity_search(query, k=10)print(docs[0].page_content)docsearch = OpenSearchVectorSearch.from_documents(    docs,    embeddings,    opensearch_url="http://localhost:9200",    engine="faiss",    space_type="innerproduct",    ef_construction=256,    m=48,)query = "What did the president say about Ketanji Brown Jackson"docs = docsearch.similarity_search(query)print(docs[0].page_content)similarity_search using Script Scoring‚Äãsimilarity_search using Script Scoring with Custom Parametersdocsearch = OpenSearchVectorSearch.from_documents(    docs, embeddings,