Skip to main content

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

  1. OPENSEARCH_HOST
  2. OPENSEARCH_REGION
  3. OPENSEARCH_USERNAME
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opensearch-helper-0.1.8.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

opensearch_helper-0.1.8-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file opensearch-helper-0.1.8.tar.gz.

File metadata

  • Download URL: opensearch-helper-0.1.8.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.5 Windows/10

File hashes

Hashes for opensearch-helper-0.1.8.tar.gz
Algorithm Hash digest
SHA256 71a024282a25ee2e760e6cc5757f591e523aa70efdc729e04684ab7b6640da60
MD5 26aa7096330160ee97a8c1bed6a7c6fb
BLAKE2b-256 719afe1b070f1d105da31af72f05e39ebbdbd079119d06cacaeb51c49ad812ec

See more details on using hashes here.

File details

Details for the file opensearch_helper-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for opensearch_helper-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 68c6185e9280195b1aeb037116ece9206823450e98e584bd7d9fc4587ef1f0b5
MD5 36e1b9743c7ee4dfbc9204f2bc4883fb
BLAKE2b-256 f14ad79ba447200f495cd3d5f1ff10866dac62ccea355c246d064b58b798f7da

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page