Simple project to test Elasticsearch with Django, build on docker.
WARNING! This project is only for local testing, it's not prepared for deployment into remote server.
- Docker
- Docker-compose
Steps to build, load data from fixtures and run project:
- Enter into root of the project
make up
make bootstrap
(in another terminal window)
To test Elasticsearch in shell run these commands:
make up
make shell
ormake bash
cars = CarDocument.search().query('match', color='black')
for car in cars:
print(car.color)
cars = CarDocument.search().extra(size=0)
cars.aggs.bucket('points_count', 'terms', field='points')
result = cars.execute()
for point in result.aggregations.points_count:
print(point)
- http://localhost:8000/cars/?query=is - search and display cars, which contain the word ‘is’ in at least one of those fields:
name
,color
,description
Check out article to this project: https://sunscrapers.com/blog/how-to-use-elasticsearch-with-django/