Initial commit of the index update scheduling support
This commit is contained in:
@@ -5,12 +5,17 @@ import logging
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.dispatch import receiver
|
||||
|
||||
from haystack.management.commands.update_index import Command
|
||||
|
||||
from navigation.api import register_sidebar_template, register_links
|
||||
from documents.models import Document
|
||||
from scheduler.runtime import scheduler
|
||||
from signaler.signals import post_update_index, pre_update_index
|
||||
from scheduler.api import register_interval_job
|
||||
from lock_manager import Lock, LockError
|
||||
|
||||
from .models import IndexableObject
|
||||
from .conf.settings import INDEX_UPDATE_INTERVAL
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -35,3 +40,27 @@ def clear_pending_indexables(sender, **kwargs):
|
||||
def scheduler_shutdown_pre_update_index(sender, **kwargs):
|
||||
logger.debug('Scheduler shut down on pre update index signal')
|
||||
scheduler.shutdown()
|
||||
|
||||
|
||||
def search_index_update():
|
||||
lock_id = u'search_index_update'
|
||||
try:
|
||||
logger.debug('trying to acquire lock: %s' % lock_id)
|
||||
lock = Lock.acquire_lock(lock_id)
|
||||
logger.debug('acquired lock: %s' % lock_id)
|
||||
|
||||
logger.debug('Executing haystack\'s index update command')
|
||||
command = Command()
|
||||
command.handle()
|
||||
|
||||
lock.release()
|
||||
except LockError:
|
||||
logger.debug('unable to obtain lock')
|
||||
pass
|
||||
|
||||
|
||||
register_interval_job('search_index_update', _(u'Update the search index with the most recent modified documents.'), search_index_update, seconds=INDEX_UPDATE_INTERVAL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,3 +13,11 @@ Setting(
|
||||
default=5,
|
||||
description=_(u'Maximum number of search queries to remember per user.')
|
||||
)
|
||||
|
||||
Setting(
|
||||
namespace=namespace,
|
||||
name='INDEX_UPDATE_INTERVAL',
|
||||
global_name='SEARCH_INDEX_UPDATE_INTERVAL',
|
||||
default=1800,
|
||||
description=_(u'Interval in second on which to trigger the search index update.')
|
||||
)
|
||||
|
||||
@@ -26,6 +26,8 @@ POP3 and IMAP
|
||||
Send document or document links via E-mail
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Haystack
|
||||
~~~~~~~~
|
||||
|
||||
Upgrading from a previous version
|
||||
=================================
|
||||
@@ -43,9 +45,12 @@ Afterwards migrate existing database schema with::
|
||||
$ ./manage.py migrate sources 0001 --fake
|
||||
$ ./manage.py migrate sources
|
||||
|
||||
#Haystack - build index
|
||||
Issue the following command to index existing documents in the new full text search database::
|
||||
|
||||
The upgrade procedure is now complete.
|
||||
$ ./manage.py rebuild_index --noinput
|
||||
|
||||
Depending on the existing size of you current document base this make take from a few minutes up to an hour.
|
||||
Once the full text initial indexing ends, the upgrade procedure is complete.
|
||||
|
||||
|
||||
Backward incompatible changes
|
||||
|
||||
Reference in New Issue
Block a user