23 lines
693 B
Python
23 lines
693 B
Python
|
import os
|
||
|
import dotenv
|
||
|
|
||
|
# Load environment variables from.env file
|
||
|
dotenv.load_dotenv()
|
||
|
|
||
|
# Connect to OpenSearch using the provided credentials and hostname/port.
|
||
|
from opensearchpy import OpenSearch
|
||
|
|
||
|
host = 'localhost'
|
||
|
port = 9200
|
||
|
auth = ('admin', os.getenv("OPENSEARCH_INITIAL_ADMIN_PASSWORD")) # For testing only. Don't store credentials in code.
|
||
|
# Create the client with SSL/TLS enabled, but hostname verification disabled.
|
||
|
opensearch_client = OpenSearch(
|
||
|
hosts=[{'host': host, 'port': port}],
|
||
|
http_compress=True, # enables gzip compression for request bodies
|
||
|
http_auth=auth,
|
||
|
use_ssl=True,
|
||
|
verify_certs=False,
|
||
|
ssl_assert_hostname=False,
|
||
|
ssl_show_warn=False
|
||
|
)
|