This project contains the code base for the X5GON search API. It connects to the Elasticsearch service and allows to search through the documents using different criteria.
-
A running Elasticsearch service (one can download and install it from here or use a docker image)
-
NodeJS version
10.x
,12.x
or>=14.x
To test that your nodejs version is correct, run
node --version
in the command line.
-
Have a running elasticsearch service
-
Create a
.env
file in the /env folder (see instructions). -
Install the nodejs dependencies:
npm install
-
Build the project components:
npm run build
The built components will be available in the
./dist
folder.
Before running the service one must have a populated elasticsearch index. Assuming that the PostgreSQL database is populated with the material documents one can run the loading script:
cd load && node create-elasticsearch-index
The script contains the schema of the elasticsearch index and the logic on how to bundle the material metadata into the index.
To manually start the Search API service one must simply run the following command:
# running in development environment
npm start
# running in production environment
cd ./dist && NODE_ENV=production node search.js
This will start the service in the terminal.
One can also run the search API using PM2. This will run the service in the background, will automatically restart if the service crashes and is fully configurable through the ./ecosystem.config.yml file.
To install PM2 one must run
npm install -g pm2
To run the service using PM2 one must simply run the following command:
pm2 start ecosystem.config.yml [--env production]
This will run the service in the background. To control the pm2 services please see their documentation.