OpenSearch Helper for Easy I/O
Project description
Open Search Helper (opensearch-helper)
A collection of methods for assisting with OpenSearch querying on AWS
MultiMatch Query Generator
Method Definition
multimatch_generator(input_text: str, size: int = 5, *args) -> MultiMatchQuery
Invoke Function
Pass in one-or-more field names after the query:
from opensearch_helper import multimatch_generator
d_query = multimatch_generator("what is the average PH of rainwater?" "question", "context")
Sample Output
{
"size":5,
"query":{
"multi_match":{
"query":"input_text",
"fields":[
"question"
]
}
}
}
API Query
Method Definition
query(d_query: MultiMatchQuery, index_name: str) -> OpenSearchResult
Invoke Function
The following environment variables must exist and be encrypted via baseblock::Run-Encrypt
- OPENSEARCH_HOST
- OPENSEARCH_REGION
- OPENSEARCH_USERNAME
- OPENSEARCH_PASSWORD
from opensearch_helper import query
query(d_query, index_name='myindex')
Score Top Hit
This method will retrieve the top hit and both quantitatively and qualitatively score the result.
Method Definition
score_top_hit(d_hits: dict) -> ScoreResult
Invoke Function
from opensearch_helper import score_top_hit
score_top_hit(d_hits)
Sample Output
{
"score":14.23432,
"type":"HIGH"
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for opensearch_helper-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb925f589623b3c60c4ac09a13ce58c0b4caf67e0543c78f843b30fe06099465 |
|
MD5 | 3064965f10c7bef5efe4a7802abb464d |
|
BLAKE2b-256 | 8644e5b0757776268c5a84950feb695a46d3be54adf47974479cbff78f6df235 |