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.3.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: opensearch-helper-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 186de7416923af5417c73bc079e7f31e61f0338259d314aab428b58cd55695dc
MD5 2cf186fae314dd88a2cc695282ef297c
BLAKE2b-256 081846858ec26fae78e986b3fe356f98b959036fe3fdd278e25be1adc965102d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opensearch_helper-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bbfb4d6acebaca547ac42e26bf034c0327328e772c503a424424b830dda82008
MD5 ca4f7bf912660719b81c7bc328777752
BLAKE2b-256 2cccf6f6da20383884da44fb44b419991e575e45ced97d7a2a67a21b8da1dc90

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