A collection of RESTful API's, written and tested using the Flask
framework of Python
language, for interacting with the Elastic-cluster
without breaking any security protocol or exposing any credentials/access tokens/confidential data.
-
Index creation:
- Creating Indices.
- Assigning ID-s.
- Timestamp is mandatory in the records that are being indexed.
-
Functionality to load the data in the system:
- Bulk indexing the data (from file).
- File should be of
csv
orjson
type. - Inserting a single document.
-
Functionality to search the data:
- Search on the basis of unique id.
- Search on the basis of any specific key value.
- Search and fetch the records in the time range given as input.
- Keyword-based search functionality.
- Full-text search functionality.
-
Aggregated info of my data.
- Create
Kibana
dashboard for the data that is inserted - Visualize and analyze the data from dashboard.
- Create
python --version
should be>=3
and<=3.10
Star and Fork the repository. Download or clone
# clone the repository
$ git clone https://github.com/atanughosh01/elasticsearch-api
$ cd elasticsearch-api
Create a virtualenv and activate it
$ python3 -m venv venv
$ . venv/bin/activate
Or on Windows cmd
$ py -3 -m venv venv
$ venv\Scripts\activate.bat
Or on Windows powershell
$ python3 -m venv venv
$ & venv\Scripts\Activate.ps1
Install pip requirements
$ pip install -U -r requirements.txt
$ export FLASK_APP=api
$ export FLASK_ENV=development
$ flask run
Or on Windows cmd
> set -x FLASK_APP=api
> set -x FLASK_ENV=development
> flask run
Or on Windows powershell
> $env:FLASK_APP = "api"
> $env:FLASK_ENV = "development"
> flask run
Create a .flaskenv
in the root
directory with the following content
export FLASK_APP=api
export FLASK_ENV=development
Make sure that python-dotenv
is installed
$ pip install python-dotenv==0.20.0
Then execute flask run
on the terminal.
Open http://127.0.0.1:5000
in a browser.
Use Postman to test the collection of API's.
-
Move to the
root
directory. -
Check if the
.flaskenv
file exists, if not create it -
Make sure whether
Docker
is running or not$ docker version $ docker images
-
Build the docker image with
Dockerfile
$ docker build -t es-api:v0.0.1 .
-
Run the docker image
$ docker run --name ElasticAPI -p 5000:5000 -d es-api:v0.0.1
-
Check the status of the container
$ docker ps
Open localhost:5000
in a browser.
Use Postman to test the collection of API's.