@@ -16,3 +16,25 @@ We use a document store and search to provide quick text searches from the API.
When a user is looking for an order, the API provides an end-point to search orders e.g. for "lcd screen", then the API does an OpenSearch query in the orders index, get N results and then read those orders from the orders table in the database (not OpenSearch) and return those results to the user.
We therefore use OpenSearch only for searching and returning a list of document ids, then read the documents from the database. A document is typically an "order" but also anything else that we need to do free text searches on.
## Testing
The dev sub-directory contains a docker-compose.yml that runs OpenSearch loccally for test programs.
Start it with:
```
cd dev
docker-compose up -d
```
Then run the go test programs in this directory...
E.g.:
```go test -v --run TestLocalWriter```
To work with this local instance from the command line:
If the test fail with index mapping error, you can delete the index before running the test, with the following command. It often happens when the code that generate the mapping changed and the existing index is incompatible with the new mapping:
Some of the test programs also refer to the cloud instance created manually in V3, e.g. search_test.go TestDevWriter(). That can be updated or deleted as required.