Additional written guidance can be also found in articles how to write search queries with OpenSearch and NodeJS and how to use aggregations with OpenSearch and NodeJS.
To run examples from this repository you'll need:
- An OpenSearch cluster. You can set it up manually or you can use a fully managed service, such as Aiven for OpenSearch.
- NodeJS and npm. If you don’t have NodeJS or npm installed, follow these instructions.
- Curiosity and patience 😉
Clone the repository and install the dependencies:
npm install
Copy .env.example, rename to .env and there the service_uri of your OpenSearch cluster.
Download full_format_recipes from Kaggle. Unzip and copy the JSON file to the root folder of this project.
Install
run-func
to run javascript methods from command line with more convenience:npm i -g run-func
You're all set! Retrieve the list of available indices by running in your terminal
run-func index getIndices
Make sure that you have full_format_recipes.json at the root level of the repository and run command to inject data:
run-func index injectData
Wait till the data is indexed. Can take 15-20 seconds.
- Check search.js and aggregate.js for examples you can run. Every method contains a terminal command sample that you can try.
run-func search match title "garlic onion cake"
run-func aggregate field rating
index.js - working with index, injecting data
search.js - examples of different types of search queries
aggregate.js - examples of different types of aggregation queries
config.js and helpers.js contain operations required to connect to the cluster and log responses.
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