mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-24 03:52:10 +00:00
docs: Update elasticsearch README (#18497)
Update Elasticsearch README with information on how to start a deployment. Also make some cosmetic changes to the [Elasticsearch docs](https://python.langchain.com/docs/integrations/vectorstores/elasticsearch). Follow up on https://github.com/langchain-ai/langchain/pull/17467
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%pip install --upgrade --quiet langchain-elasticsearch langchain-openai tiktoken langchain"
|
||||
"%pip install --upgrade --quiet langchain-elasticsearch langchain-openai tiktoken langchain"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -57,61 +57,61 @@
|
||||
"Example: Run a single-node Elasticsearch instance with security disabled. This is not recommended for production use.\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
" docker run -p 9200:9200 -e \"discovery.type=single-node\" -e \"xpack.security.enabled=false\" -e \"xpack.security.http.ssl.enabled=false\" docker.elastic.co/elasticsearch/elasticsearch:8.9.0\n",
|
||||
"docker run -p 9200:9200 -e \"discovery.type=single-node\" -e \"xpack.security.enabled=false\" -e \"xpack.security.http.ssl.enabled=false\" docker.elastic.co/elasticsearch/elasticsearch:8.12.1\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"Once the Elasticsearch instance is running, you can connect to it using the Elasticsearch URL and index name along with the embedding object to the constructor.\n",
|
||||
"\n",
|
||||
"Example:\n",
|
||||
"```python\n",
|
||||
" from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
" from langchain_openai import OpenAIEmbeddings\n",
|
||||
"from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
"from langchain_openai import OpenAIEmbeddings\n",
|
||||
"\n",
|
||||
" embedding = OpenAIEmbeddings()\n",
|
||||
" elastic_vector_search = ElasticsearchStore(\n",
|
||||
" es_url=\"http://localhost:9200\",\n",
|
||||
" index_name=\"test_index\",\n",
|
||||
" embedding=embedding\n",
|
||||
" )\n",
|
||||
"embedding = OpenAIEmbeddings()\n",
|
||||
"elastic_vector_search = ElasticsearchStore(\n",
|
||||
" es_url=\"http://localhost:9200\",\n",
|
||||
" index_name=\"test_index\",\n",
|
||||
" embedding=embedding\n",
|
||||
")\n",
|
||||
"```\n",
|
||||
"### Authentication\n",
|
||||
"For production, we recommend you run with security enabled. To connect with login credentials, you can use the parameters `es_api_key` or `es_user` and `es_password`.\n",
|
||||
"\n",
|
||||
"Example:\n",
|
||||
"```python\n",
|
||||
" from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
" from langchain_openai import OpenAIEmbeddings\n",
|
||||
"from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
"from langchain_openai import OpenAIEmbeddings\n",
|
||||
"\n",
|
||||
" embedding = OpenAIEmbeddings()\n",
|
||||
" elastic_vector_search = ElasticsearchStore(\n",
|
||||
" es_url=\"http://localhost:9200\",\n",
|
||||
" index_name=\"test_index\",\n",
|
||||
" embedding=embedding,\n",
|
||||
" es_user=\"elastic\",\n",
|
||||
" es_password=\"changeme\"\n",
|
||||
" )\n",
|
||||
"embedding = OpenAIEmbeddings()\n",
|
||||
"elastic_vector_search = ElasticsearchStore(\n",
|
||||
" es_url=\"http://localhost:9200\",\n",
|
||||
" index_name=\"test_index\",\n",
|
||||
" embedding=embedding,\n",
|
||||
" es_user=\"elastic\",\n",
|
||||
" es_password=\"changeme\"\n",
|
||||
")\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"You can also use an `Elasticsearch` client object that gives you more flexibility, for example to configure the maximum number of retries.\n",
|
||||
"\n",
|
||||
"Example:\n",
|
||||
"```python\n",
|
||||
" import elasticsearch\n",
|
||||
" from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
"import elasticsearch\n",
|
||||
"from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
"\n",
|
||||
" es_client= elasticsearch.Elasticsearch(\n",
|
||||
" hosts=[\"http://localhost:9200\"],\n",
|
||||
" es_user=\"elastic\",\n",
|
||||
" es_password=\"changeme\"\n",
|
||||
" max_retries=10,\n",
|
||||
" )\n",
|
||||
"es_client= elasticsearch.Elasticsearch(\n",
|
||||
" hosts=[\"http://localhost:9200\"],\n",
|
||||
" es_user=\"elastic\",\n",
|
||||
" es_password=\"changeme\"\n",
|
||||
" max_retries=10,\n",
|
||||
")\n",
|
||||
"\n",
|
||||
" embedding = OpenAIEmbeddings()\n",
|
||||
" elastic_vector_search = ElasticsearchStore(\n",
|
||||
" index_name=\"test_index\",\n",
|
||||
" es_connection=es_client,\n",
|
||||
" embedding=embedding,\n",
|
||||
" )\n",
|
||||
"embedding = OpenAIEmbeddings()\n",
|
||||
"elastic_vector_search = ElasticsearchStore(\n",
|
||||
" index_name=\"test_index\",\n",
|
||||
" es_connection=es_client,\n",
|
||||
" embedding=embedding,\n",
|
||||
")\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"#### How to obtain a password for the default \"elastic\" user?\n",
|
||||
@@ -137,17 +137,17 @@
|
||||
"\n",
|
||||
"Example:\n",
|
||||
"```python\n",
|
||||
" from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
" from langchain_openai import OpenAIEmbeddings\n",
|
||||
"from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
"from langchain_openai import OpenAIEmbeddings\n",
|
||||
"\n",
|
||||
" embedding = OpenAIEmbeddings()\n",
|
||||
" elastic_vector_search = ElasticsearchStore(\n",
|
||||
" es_cloud_id=\"<cloud_id>\",\n",
|
||||
" index_name=\"test_index\",\n",
|
||||
" embedding=embedding,\n",
|
||||
" es_user=\"elastic\",\n",
|
||||
" es_password=\"changeme\"\n",
|
||||
" )\n",
|
||||
"embedding = OpenAIEmbeddings()\n",
|
||||
"elastic_vector_search = ElasticsearchStore(\n",
|
||||
" es_cloud_id=\"<cloud_id>\",\n",
|
||||
" index_name=\"test_index\",\n",
|
||||
" embedding=embedding,\n",
|
||||
" es_user=\"elastic\",\n",
|
||||
" es_password=\"changeme\"\n",
|
||||
")\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
|
Reference in New Issue
Block a user