Commit 5314a216 authored by Michal Čihař's avatar Michal Čihař

Add management command to optimize fulltext index.

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 22bb357f
......@@ -238,6 +238,10 @@ have huge set of translation units.
You can use ``--clean`` to remove all words from database prior updating.
With ``--optimize`` the index will not be processed again, only it's content
will be optimized (removing stale entries and merging possibly split index
files).
.. seealso:: :ref:`fulltext`
update_index
......
......@@ -16,6 +16,7 @@ Released on ? 2015.
* Several URLs have changed, you might have to update your bookmarks.
* Hook scripts are executed with VCS root as current directory.
* Hook scripts are executed with environment variables descriping current component.
* Add management command to optimize fulltext index.
weblate 2.3
-----------
......
......@@ -24,6 +24,7 @@ from weblate.trans.search import (
update_source_unit_index, update_target_unit_index,
clean_indexes,
)
from weblate.lang.models import Language
from optparse import make_option
......@@ -37,9 +38,25 @@ class Command(WeblateCommand):
default=False,
help='removes also all words from database'
),
make_option(
'--optimize',
action='store_true',
dest='optimize',
default=False,
help='optimize index without rebuilding it'
),
)
def handle(self, *args, **options):
# Optimize index
if options['optimize']:
index = get_source_index()
index.optimize()
languages = Language.objects.have_translation()
for lang in languages:
index = get_target_index(lang.code)
index.optimize()
return
# Optionally rebuild indices from scratch
if options['clean']:
clean_indexes()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment