langchain icon indicating copy to clipboard operation
langchain copied to clipboard

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

Open lemig opened this issue 1 year ago • 3 comments

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

lemig avatar May 25 '23 12:05 lemig

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 ?

jeffvestal avatar May 26 '23 00:05 jeffvestal

I would rather pass ES client. If not, I need to pass an elasticsearch url plus elastic client options. See ssl_verify param in: https://github.com/hwchase17/langchain/commit/039f8f1abb03cc7983282bfa285920d00231e360#diff-6df1e93fbce8079475f40ff4465b79aa5e41131e63eb1d3c57b42b7779cb7adbR137

lemig avatar May 26 '23 08:05 lemig

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

jeffvestal avatar May 26 '23 15:05 jeffvestal

@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,
)

jeffvestal avatar May 31 '23 01:05 jeffvestal

Awesome. Thanks @jeffvestal & Elastic!

lemig avatar May 31 '23 07:05 lemig