ded-should-index-example

requirements :

  • Running elasticsearch
  • Python virtualenv

How to test :

pip install -r requirements.txt

Change ELASTICSEARCH_DSL['default']['hosts'] in settings.py

./manage.py migrate

./manage.py shell

from pizzeria.models import Pizza
pizza = Pizza.objects.first()
pizza.save()

curl http://elasticsearch-hostname:9200/pizzas/_search/

Our pizza is indexed, everything is fine

pizza.delete()

We can see should_index_object print no toppings and False
Which is normal in django ways but our pizza is still indexed while not existing in database