This repository contains code examples related to OpenSearch with Python queries.
- 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
You can download the dataset from Kaggle recipe dataset, and save the file as recipes.json
in this current folder.
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:
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
Install all dependencies:
pip install -r requirements.txt
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>
Feel free to open an issue with your question on Issues or drop me a message at laysa.uchoa@gmail.com
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
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.