Using fuzzy logic even if the search keyword is misspelled or a long sentence, the results will be matched. [See query 2]
- Django==4.1.1
- djangorestframework==3.13.1
- elasticsearch==7.13.4
- elasticsearch-dsl==7.4.0
- django-elasticsearch-dsl==7.2.2
To install elastic search please follow my article https://mahmudtopu3.medium.com/play-with-elastic-search-with-python-django-on-ubuntu-part-1-d063af7edc00
-
Clone Project from github and add database information and elasticsearch information in settings.py
-
Create virtualenv
$ python -m venv venv
-
Activate Virtualenv
$ venv/Scripts/activate
-
Make migration
$ python manage.py makemigrations
-
Migrate
$ python manage.py migrate
-
Create Superuser
$ python manage.py createsuperuser
-
Start Server
$ python manage.py runserver
-
Load Demo data
$ python manage.py loaddata hrm.json
-
Index data to elastic search
$ python manage.py search_index --rebuild
ELASTICSEARCH_DSL = {
'default': {
'hosts': 'http://elastic:123456@localhost:9200/',
# also can be basic auth url
},
}
http://localhost:9200/hrm_index/_mapping
http://127.0.0.1:8000/hrm/all-employees?search=software&company=Daffodil%20Family
http://127.0.0.1:8000/hrm/all-employees?search=softwae
http://127.0.0.1:8000/hrm/all-employees?search=software&courses=Business%20Communication
http://127.0.0.1:8000/hrm/all-employees?search=software&courses=Database
http://127.0.0.1:8000/hrm/all-employees?search=software&company=Daffodil%20Family&courses=Database
http://127.0.0.1:8000/hrm/all-employees?search=softwre&courses=Complr
http://127.0.0.1:8000/hrm/all-employees?search=softwre&courses=Dataase
http://127.0.0.1:8000/hrm/all-employees?search=softwre&skills=Elastic%20Search
http://127.0.0.1:8000/hrm/all-employees?search=engineer&skills=python
http://127.0.0.1:8000/hrm/all-employees?search=developer&skills=python
http://127.0.0.1:8000/hrm/all-employees?courses=Accounting
http://127.0.0.1:8000/hrm/all-employees?search=software&exp_gte=3&exp_lte=5
http://127.0.0.1:8000/hrm/all-employees?search=software&exp_gte=4.1&exp_lte=5
http://127.0.0.1:8000/hrm/all-employees?search=engineer&skills=java
http://127.0.0.1:8000/hrm/all-employees?search=engineer&skills=java&level=INTERMEDIATE
http://127.0.0.1:8000/hrm/all-employees?search=engineer&skills=elastic&level=INTERMEDIATE