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 (AWS)

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')

Local OpenSearch

From the terminal run

docker-compose up

The following environment variables must exist and be encrypted via baseblock::Run-Encrypt

  1. OPENSEARCH_HOST
  2. OPENSEARCH_USERNAME
  3. OPENSEARCH_PASSWORD

Unless these have been modified, the default values can be found here https://opensearch.org/docs/latest/opensearch/install/docker/

from a python script import

from opensearch_helper import OpenSearchDEV

The following functions are available

client = OpenSearchDEV()

client.create_index(...)
client.delete_index(...)
client.add(...)
client.query(...)

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

Uploaded Source

Built Distribution

opensearch_helper-0.1.28-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file opensearch_helper-0.1.28.tar.gz.

File metadata

  • Download URL: opensearch_helper-0.1.28.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.5 Windows/10

File hashes

Hashes for opensearch_helper-0.1.28.tar.gz
Algorithm Hash digest
SHA256 7f605bc46bcdc69c8d4e3d1aa442b735fbaa1cb191d53bcf9ec9b1cf2fbdb659
MD5 58125e27f0ce2b6379afbc796799d669
BLAKE2b-256 af9e86f163c6d1416b75938db6e087d222cbd3b209689c8ec51128c64e14752e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opensearch_helper-0.1.28-py3-none-any.whl
Algorithm Hash digest
SHA256 033a7a04c90695e5acf7d219cee4ef7205339b4d9f5a40db7306ddd357f1beb8
MD5 410bea5af02f4cb941fedbc8999907b9
BLAKE2b-256 993bb4f688dc48107d7475c26a869a386efcbf4ceacb317b1790de610efb0a68

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