Skip to content

This repository contains code example in how to write search queries with OpenSearch Python client

License

Notifications You must be signed in to change notification settings

Aiven-Labs/demo-opensearch-python

Repository files navigation

OpenSearch® search queries with Python

This repository contains code examples related to OpenSearch with Python queries.

Repository structure

  • config.py, basic information to connect to the cluster
  • index.py, contains methods that manipulate the index
  • search.py, contains search queries methods
  • helpers.py, response handler of search requests

Dataset

You can download the dataset from Kaggle recipe dataset, and save the full_format_recipes.json in the current folder of the demo.

Search examples

The available search options can be found by using help command:

python search.py --help

Find the arguments to be passed to a certain function by running:

python search.py OPTION --help

OPTION can be:

Quickstart

To run those examples you need: * Python 3.7+. * An OpenSearch® cluster. It can be set it up manually or you can use a fully managed service, such as Aiven for OpenSearch®. * OpenSearch cluster Service URI

Dependencies

Install all dependencies:

pip install -r requirements.txt

Service URI

To connect with your cluster, you need the Service URI of your OpenSearch cluster. You can find the connection details in the section Overview on Aiven web console. Notice that service_uri contains credentials; therefore, should be treated with care.

This project uses dotenv Python library to manage the environment variables.

Replace your SERVICE_URI on .env file with yours as string:

SERVICE_URI=<https://<user>:<password>@<host>:<port>

Do you have questions?

Feel free to open an issue with your question on Issues or ask a question on the Aiven community forum

License

This work is licensed under the Apache License, Version 2.0. Full license text is available in the LICENSE file and at http://www.apache.org/licenses/LICENSE-2.0.txt

Trademarks

OpenSearch, Python are trademarks and property of their respective owners. All product and service names used in this website are for identification purposes only and do not imply endorsement.

About

This repository contains code example in how to write search queries with OpenSearch Python client

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages