Check out the post.
-
Fork/Clone
-
Install Elasticsearch if you haven't already and make sure it is running on port
9200
. -
Create and activate a virtual environment:
$ python3 -m venv venv && source venv/bin/activate
-
Install the requirements:
(venv)$ pip install -r requirements.txt
-
Apply the migrations:
(venv)$ python manage.py migrate
-
Populate the database with some test data by running the following command:
(venv)$ python manage.py populate_db
-
Create and populate the Elasticsearch index and mapping:
(venv)$ python manage.py search_index --rebuild
-
Run the server
(venv)$ python manage.py runserver
-
Test Elasticsearch with the following queries:
- http://127.0.0.1:8000/search/user/mike/ - should find the user 'mike13'
- http://127.0.0.1:8000/search/user/jess_/ - should find the user 'jess_'
- http://127.0.0.1:8000/search/category/seo/ - should find the category 'SEO optimization'
- http://127.0.0.1:8000/search/category/progreming/ - should find the category 'Programming' (:warning: notice the typo)
- http://127.0.0.1:8000/search/article/linux/ - should find the article 'Installing the latest version of Ubuntu'
- http://127.0.0.1:8000/search/article/java/ - should find the article 'Which programming language is the best?'