From eebbf7355d48b45606422a3036d4c0acb045a94d Mon Sep 17 00:00:00 2001 From: Jeffrey S Rengifo Marin <97353049+Delacrobix@users.noreply.github.com> Date: Thu, 14 Aug 2025 12:37:08 -0500 Subject: [PATCH] Building elasticsearch apis with fastapi websockets - style changes (#477) --- .../README.md | 23 ++- .../index.html | 175 +++++++++++------- .../inegst_data.py | 4 +- 3 files changed, 135 insertions(+), 67 deletions(-) diff --git a/supporting-blog-content/building-elasticsearch-apis-with-fastapi-websockets/README.md b/supporting-blog-content/building-elasticsearch-apis-with-fastapi-websockets/README.md index 825f761a..fb52be2d 100644 --- a/supporting-blog-content/building-elasticsearch-apis-with-fastapi-websockets/README.md +++ b/supporting-blog-content/building-elasticsearch-apis-with-fastapi-websockets/README.md @@ -25,7 +25,28 @@ python3 -m venv venv pip install -r requirements.txt ``` -4. **Run the API with uvicorn:** +4. **Set up Elasticsearch credentials:** + +Set your Elasticsearch endpoint and API key as environment variables: + +```bash +export ELASTICSEARCH_ENDPOINT="your-elasticsearch-endpoint" +export ELASTICSEARCH_API_KEY="your-elasticsearch-api-key" +``` + +5. **Create the index and load data:** + +Run the ingest script to create the products index and load the sample data: + +```bash +python ingest_data.py +``` + +This will: +- Create the `products` index with the proper mapping +- Load all products from `products.ndjson` into Elasticsearch + +6. **Run the API with uvicorn:** ```bash uvicorn main:app --reload diff --git a/supporting-blog-content/building-elasticsearch-apis-with-fastapi-websockets/index.html b/supporting-blog-content/building-elasticsearch-apis-with-fastapi-websockets/index.html index 273f624c..4badaded 100644 --- a/supporting-blog-content/building-elasticsearch-apis-with-fastapi-websockets/index.html +++ b/supporting-blog-content/building-elasticsearch-apis-with-fastapi-websockets/index.html @@ -4,51 +4,88 @@