batiste/django-page-cms — Issue #50: Bug with RealTimePageIndex haystack search
Author: tomt-sc
Created: 2012-02-16 12:35:47+00:00
State: open

When saving a page as draft while using RealTimePageIndex, it is added to/updated within the search index. This is incorrect and also fails as the publication_date field is NULL.

This presumably also happens for any draft pages that exist when real time indexing is not used but update_index is called.

A possible fix is to add:

def should_update(self, instance, **kwargs):
if instance.status == Page.PUBLISHED:
return True
return False

to the PageIndex and RealTimePageIndex classes within search_indexes.py (this only updates the index with the current instance if it has been published). It may also be worth attempting removal of the instance in case it was added previously as a published page and now changed to draft.

Thanks.