-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Nested search params in ES config (#120)
* refactor: Nested search params in ES config Co-authored-by: filipe oliveira <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: Remove extra config vars * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: Remove extra comment * feat: Add keyword, text, and float index types in ES --------- Co-authored-by: filipe oliveira <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2ffe5e2
commit 5f2121e
Showing
4 changed files
with
38 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,24 @@ | ||
ELASTIC_PORT = 9200 | ||
ELASTIC_INDEX = "bench" | ||
ELASTIC_USER = "elastic" | ||
ELASTIC_PASSWORD = "passwd" | ||
import os | ||
|
||
from elasticsearch import Elasticsearch | ||
|
||
ELASTIC_PORT = int(os.getenv("ELASTIC_PORT", 9200)) | ||
ELASTIC_INDEX = os.getenv("ELASTIC_INDEX", "bench") | ||
ELASTIC_USER = os.getenv("ELASTIC_USER", "elastic") | ||
ELASTIC_PASSWORD = os.getenv("ELASTIC_PASSWORD", "passwd") | ||
|
||
|
||
def get_es_client(host, connection_params): | ||
init_params = { | ||
"verify_certs": False, | ||
"retry_on_timeout": True, | ||
"ssl_show_warn": False, | ||
**connection_params, | ||
} | ||
client = Elasticsearch( | ||
f"http://{host}:{ELASTIC_PORT}", | ||
basic_auth=(ELASTIC_USER, ELASTIC_PASSWORD), | ||
**init_params, | ||
) | ||
assert client.ping() | ||
return client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters