liberation / django-elasticsearch

Simple wrapper around elasticsearch-py to index/search a django Model.
MIT License
211 stars 73 forks source link

Auto Indexing on Already saved data #52

Closed Dean-Christian-Armada closed 8 years ago

Dean-Christian-Armada commented 8 years ago

There are instances where you will use this library on the later parts of development..

In my case,, I just used this library and every data that is already saved before I install this package is not indexed..

By setting ELASTICSEARCH_AUTO_INDEX to true,, everything that will be saved will contain an index.. This will enable me to set index to every data that is already saved by updating or resaving it which is done manually or a lot easier approach is by re-saving them via for loop

But is there an easier way? or something easier can be done to do that? like a manage.py command or something?

lauxley commented 8 years ago

You can call

MyModel.es.create_index()
MyModel.es.index_all()

or

MyModel.es.flush()

which deletes the index before reindexing everything.

Dean-Christian-Armada commented 8 years ago

Oh ok Thanks!