An application that exposes microservices under web api, by leveraging the greatness of Elasticsearch with nodejs.
| -- /public
| -- packages.json
| -- /src
| -- /app
| -- /services
| -- /Shared -> contains all models
| -- /views
| -- /server
| -- packages.json
| -- /datasamples
| -- /src
| -- /controllers
| -- /routes
| -- /shared -> contains all models
| -- /test -> tests driven development using Mocha
| -- packages.json -> contains global npm commands for public + server's packages.json files.
-
Start elasticsearch cluster first.
-
In order to create the product index, the data file is available in server\datasamples directory.
Command to bulk insert products from file products-bulk.json :
POST /product/default/_bulk
[put here file content]
- Activate/Deactivate the server-side trace of elasticsearch client in elastic_config.js :
const esclient = new elasticsearch.Client({
host: 'localhost:9200',
log: 'trace'
});
- For each directories public and server, install packages using this following command:
npm install
- In the root directory, open 2 separate terminals and type following commands in the order :
1.1. To start ElasticSearch Cluster on server-side:
npm run start:server:es
2.2. Then, to start client and server:
npm start
- Launch web client on a browser using url:\
Green light means server is up.
Red light means server is down.
Reason is elasticsearch cluster down and need to be started. Check step 1.1.
- To launch unit tests (server must be shutdown), make sure elasticsearch cluster is started.
npm run test:server
- To launch tests with minimal logs:
npm run test:server:noverbose
https://marcobonzanini.com/2015/02/09/phrase-match-and-proximity-search-in-elasticsearch/