File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
supporting-blog-content/building-multimodal-rag-with-elasticsearch-gotham/src Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -15,10 +15,24 @@ def __init__(self):
1515
1616 def _connect_elastic (self ):
1717 """Connects to Elasticsearch"""
18- return Elasticsearch (
19- os .getenv ("ELASTICSEARCH_ENDPOINT" ), # Elasticsearch endpoint
20- api_key = os .getenv ("ELASTIC_API_KEY" )
21- )
18+ ELASTICSEARCH_URL = os .getenv ("ELASTICSEARCH_URL" )
19+ ELASTICSEARCH_USER = os .getenv ("ELASTICSEARCH_USER" )
20+ ELASTICSEARCH_PASSWORD = os .getenv ("ELASTICSEARCH_PASSWORD" )
21+ ELASTICSEARCH_API_KEY = os .getenv ("ELASTICSEARCH_API_KEY" )
22+
23+ if ELASTICSEARCH_USER :
24+ return Elasticsearch (
25+ hosts = [ELASTICSEARCH_URL ],
26+ basic_auth = (ELASTICSEARCH_USER , ELASTICSEARCH_PASSWORD ),
27+ )
28+ elif ELASTICSEARCH_API_KEY :
29+ return Elasticsearch (
30+ hosts = [ELASTICSEARCH_URL ], api_key = ELASTICSEARCH_API_KEY
31+ )
32+ else :
33+ raise ValueError (
34+ "Please provide either ELASTICSEARCH_USER or ELASTICSEARCH_API_KEY"
35+ )
2236
2337 def _setup_index (self ):
2438 """Sets up the index if it doesn't exist"""
You can’t perform that action at this time.
0 commit comments