Searching Tool is a DRF-based project to search through huge amounts of data. The data is scraped from websites.
First, the data is scrapped from multiple websites and stored in an SQL database (Postgres).
Now, To search through such a huge amount of data, we used elasticsearch
.
Python Version: 3.10.6
Assumption: The project is cloned, and the current working directory in terminal/cmd is /Searching-Tool
.
Install Python Virtual Environment
To Activate the virtual environment
For Linux
source myenv/bin/activate
For Windows
myenv\Scripts\activate
pip install -r requirements.txt
Create a .env
file
# For Linux
cp sample_env.txt .env
# For Windows
copy sample_env.txt .env
Change environment variables in the .env
file
SETTINGS_MODULE_NAME
:dev
ACCESS_TOKEN_LIFETIME
:3600
# This value represent amount of time(in sec) to expire after creation of access_tokenREFRESH_TOKEN_LIFETIME
:86400
# This value represent amount of time(in sec) to expire after creation of refresh_tokenFRONT_END_DOMAIN
:http://localhost:3000
# This variable is used for creating links in send_email functionalityBACK_END_DOMAIN
:http://localhost:8000
# This variable is used for creating links in send_email functionalityPASSWORD_RESET_TIMEOUT
:60
# This value represents the amount of time(in seconds) to expire after creation, Using PasswordResetTokenGenerator (Used in Forgotpassword Api)INQUIRY_EMAIL
:[email protected]
# This email will receive inquiry emailsDB_NAME
:database_name
DB_USER
:database_user_name
DB_PASS
:database_user_password
DB_PORT
:database_port
DB_HOST
:database_host
EMAIL_HOST_USER
:email address
# This email is used in send_email functionality to send mails to usersEMAIL_HOST_PASSWORD
:app password
# This is app password created from Google accountELASTICSEARCH_USERNAME
:elastic
# This is username of elasticsearch serverELASTICSEARCH_PASSWORD
:password
# This is password of elasticsearch serverELASTICSEARCH_HOST_IP
:localhost
# This is host ip of elasticsearch serverELASTICSEARCH_HOST_PORT
:9200
# This is host port of elasticsearch serverFRAMEWORK_INDEX_NAME
:framework_test
# This is index name of framework in elasticsearch
Run the below commands to create tables in the database
python manage.py makemigrations
python manage.py migrate
Follow steps in [Guide](https://www.elastic.co/guide/en/elasticsearch/reference/current/run-elasticsearch-locally.html)
To run Local Development Server, run the below cmd
python manage.py runserver
To run using GUNICORN
gunicorn core.wsgi:application --bind 0.0.0.0:8000 --timeout 600 --daemon
Run below command
python manage.py survey_init
Run below command
python manage.py framework_values
Run below command
python manage.py populate_frameworks
Run below command
# Delete index and rebuild
python manage.py search_index --rebuild
# Create index if not and update
python manage.py search_index --populate
Run the below command
python manage.py deletedocuments 32929 92828 58593