Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: ElasticsearchEmbeddings does not work on hosted elasticsearch (Platinum) #5239

Closed
lemig opened this issue May 25, 2023 · 5 comments
Closed
Assignees

Comments

@lemig
Copy link

lemig commented May 25, 2023

Issue you'd like to raise.

LangChain 0.0.179, hosted elasticsearch (Platinum edition)

V0.0.179 introduced elasticsearch embeddings, great!

But it is only implemented for elastic cloud.

I want to be able to do embeddings on my own elastic cluster.

@jeffvestal @derickson

Suggestion:

No response

@jeffvestal
Copy link
Contributor

I can add in the ability to use a url (the elasticsearch url) to the connection object rather than the cloud_id.

Would that work for you @lemig ?

@lemig
Copy link
Author

lemig commented May 26, 2023

I would rather pass ES client.
If not, I need to pass an elasticsearch url plus elastic client options.
See ssl_verify param in: 039f8f1#diff-6df1e93fbce8079475f40ff4465b79aa5e41131e63eb1d3c57b42b7779cb7adbR137

@jeffvestal
Copy link
Contributor

That should work. I'll take a look at it soon.

dev2049 added a commit that referenced this issue May 31, 2023
…bject (#5321)

This PR adds a new method `from_es_connection` to the
`ElasticsearchEmbeddings` class allowing users to use Elasticsearch
clusters outside of Elastic Cloud.

Users can create an Elasticsearch Client object and pass that to the new
function.
The returned object is identical to the one returned by calling
`from_credentials`

```
# Create Elasticsearch connection
es_connection = Elasticsearch(
    hosts=['https://es_cluster_url:port'], 
    basic_auth=('user', 'password')
)

# Instantiate ElasticsearchEmbeddings using es_connection
embeddings = ElasticsearchEmbeddings.from_es_connection(
  model_id,
  es_connection,
)
```

I also added examples to the elasticsearch jupyter notebook

Fixes # #5239

---------

Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
@jeffvestal
Copy link
Contributor

@lemig PR was merged.

# Create Elasticsearch connection
es_connection = Elasticsearch(
    hosts=['https://es_cluster_url:port'], 
    basic_auth=('user', 'password')
)

# Instantiate ElasticsearchEmbeddings using es_connection
embeddings = ElasticsearchEmbeddings.from_es_connection(
  model_id,
  es_connection,
)

@lemig
Copy link
Author

lemig commented May 31, 2023

Awesome. Thanks @jeffvestal & Elastic!

@lemig lemig closed this as completed May 31, 2023
vowelparrot pushed a commit that referenced this issue May 31, 2023
…bject (#5321)

This PR adds a new method `from_es_connection` to the
`ElasticsearchEmbeddings` class allowing users to use Elasticsearch
clusters outside of Elastic Cloud.

Users can create an Elasticsearch Client object and pass that to the new
function.
The returned object is identical to the one returned by calling
`from_credentials`

```
# Create Elasticsearch connection
es_connection = Elasticsearch(
    hosts=['https://es_cluster_url:port'], 
    basic_auth=('user', 'password')
)

# Instantiate ElasticsearchEmbeddings using es_connection
embeddings = ElasticsearchEmbeddings.from_es_connection(
  model_id,
  es_connection,
)
```

I also added examples to the elasticsearch jupyter notebook

Fixes # #5239

---------

Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
Undertone0809 pushed a commit to Undertone0809/langchain that referenced this issue Jun 19, 2023
…bject (langchain-ai#5321)

This PR adds a new method `from_es_connection` to the
`ElasticsearchEmbeddings` class allowing users to use Elasticsearch
clusters outside of Elastic Cloud.

Users can create an Elasticsearch Client object and pass that to the new
function.
The returned object is identical to the one returned by calling
`from_credentials`

```
# Create Elasticsearch connection
es_connection = Elasticsearch(
    hosts=['https://es_cluster_url:port'], 
    basic_auth=('user', 'password')
)

# Instantiate ElasticsearchEmbeddings using es_connection
embeddings = ElasticsearchEmbeddings.from_es_connection(
  model_id,
  es_connection,
)
```

I also added examples to the elasticsearch jupyter notebook

Fixes # langchain-ai#5239

---------

Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants