docs, embeddings, opensearch_url="http://localhost:9200", is_appx_search=False)query = "What did the president say about Ketanji Brown Jackson"docs = docsearch.similarity_search(    "What did the president say about Ketanji Brown Jackson",    k=1,    search_type="script_scoring",)print(docs[0].page_content)similarity_search using Painless Scripting‚Äãsimilarity_search using Painless Scripting with Custom Parametersdocsearch = OpenSearchVectorSearch.from_documents(    docs, embeddings, opensearch_url="http://localhost:9200", is_appx_search=False)filter = {"bool": {"filter": {"term": {"text": "smuggling"}}}}query = "What did the president say about Ketanji Brown Jackson"docs = docsearch.similarity_search(    "What did the president say about Ketanji Brown Jackson",    search_type="painless_scripting",    space_type="cosineSimilarity",    pre_filter=filter,)print(docs[0].page_content)Maximum marginal relevance search (MMR)‚ÄãIf you‚Äôd like to look up for some similar documents, but you‚Äôd also like to receive diverse results, MMR is method you should consider. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents.query = "What did the president say about Ketanji Brown Jackson"docs = docsearch.max_marginal_relevance_search(query, k=2, fetch_k=10, lambda_param=0.5)Using a preexisting OpenSearch instance‚ÄãIt's also possible to use a preexisting OpenSearch instance with documents that already have vectors present.# this is just an example, you would need to change these values to point to another opensearch instancedocsearch = OpenSearchVectorSearch(    index_name="index-*",    embedding_function=embeddings,    opensearch_url="http://localhost:9200",)# you can specify custom field names to match the fields you're using to store your embedding, document text value, and metadatadocs = docsearch.similarity_search(    "Who was asking about getting lunch today?",    search_type="script_scoring",    space_type="cosinesimil",
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. ->: docs, embeddings, opensearch_url="http://localhost:9200", is_appx_search=False)query = "What did the president say about Ketanji Brown Jackson"docs = docsearch.similarity_search(    "What did the president say about Ketanji Brown Jackson",    k=1,    search_type="script_scoring",)print(docs[0].page_content)similarity_search using Painless Scripting‚Äãsimilarity_search using Painless Scripting with Custom Parametersdocsearch = OpenSearchVectorSearch.from_documents(    docs, embeddings, opensearch_url="http://localhost:9200", is_appx_search=False)filter = {"bool": {"filter": {"term": {"text": "smuggling"}}}}query = "What did the president say about Ketanji Brown Jackson"docs = docsearch.similarity_search(    "What did the president say about Ketanji Brown Jackson",    search_type="painless_scripting",    space_type="cosineSimilarity",    pre_filter=filter,)print(docs[0].page_content)Maximum marginal relevance search (MMR)‚ÄãIf you‚Äôd like to look up for some similar documents, but you‚Äôd also like to receive diverse results, MMR is method you should consider. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents.query = "What did the president say about Ketanji Brown Jackson"docs = docsearch.max_marginal_relevance_search(query, k=2, fetch_k=10, lambda_param=0.5)Using a preexisting OpenSearch instance‚ÄãIt's also possible to use a preexisting OpenSearch instance with documents that already have vectors present.# this is just an example, you would need to change these values to point to another opensearch instancedocsearch = OpenSearchVectorSearch(    index_name="index-*",    embedding_function=embeddings,    opensearch_url="http://localhost:9200",)# you can specify custom field names to match the fields you're using to store your embedding, document text value, and metadatadocs = docsearch.similarity_search(    "Who was asking about getting lunch today?",    search_type="script_scoring",    space_type="cosinesimil",