From 7d19c933ac8dcc7784bfff2262e630324bc455c8 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 22 Mar 2022 15:33:51 +0800 Subject: [PATCH] add elastic in README --- packages/api/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/api/README.md b/packages/api/README.md index 93b0e41e0..847ba6c16 100644 --- a/packages/api/README.md +++ b/packages/api/README.md @@ -16,6 +16,18 @@ All operations on the database must be wrapped in Knex transaction on a resolver Because we make use of Row Level Security in the database, - all operations typically begin with assuming the role for which policies exist via `omnivore.set_claims` database function. +## ElasticSearch + +We use ElasticSearch to store page data in a distributed manner. This is a great way to store data that is not easily searchable. +All the page data is stored in a single index `pages`. This index is then queried by the app to display the data. +You need to make sure you have an elasticsearch instance running locally (or just use docker-compose). +ES url is specified by `ES_URL` environment variable (username `ES_USERNAME` and password `ES_PASSWORD` can be random strings in local environment). + +When you're running elastic for the very first time, you need to create indices and ingest existing data. This can be done by running `python elastic_migrate.py`. +This operation is idempotent, so you can always run `python elastic_migrate.py` again to re-ingest all the data. + +You can run ElasticSearch separately by using `docker-compose -f docker-compose.yml up -d elastic`. + ## Image Proxy (optional for local dev) Backend API server returns article image links using image proxy