Adds functional 'slim' indexing
This commit is contained in:
parent
5bb313971f
commit
0a9ccc4e2e
|
@ -36,7 +36,13 @@ def rebuild_index_for_model(model_, engine_slug_, verbosity_, slim_=False):
|
||||||
local_refreshed_model_count = [0] # HACK: Allows assignment to outer scope.
|
local_refreshed_model_count = [0] # HACK: Allows assignment to outer scope.
|
||||||
|
|
||||||
def iter_search_entries():
|
def iter_search_entries():
|
||||||
for obj in model_._default_manager.all().iterator():
|
# Only index specified objects if slim_ is True
|
||||||
|
if slim_ and search_engine_._registered_models[model_].get_live_queryset():
|
||||||
|
obj_list = search_engine_._registered_models[model_].get_live_queryset()
|
||||||
|
else:
|
||||||
|
obj_list = model_._default_manager.all()
|
||||||
|
|
||||||
|
for obj in obj_list.iterator():
|
||||||
for search_entry in search_engine_._update_obj_index_iter(obj):
|
for search_entry in search_engine_._update_obj_index_iter(obj):
|
||||||
yield search_entry
|
yield search_entry
|
||||||
local_refreshed_model_count[0] += 1
|
local_refreshed_model_count[0] += 1
|
||||||
|
@ -82,7 +88,7 @@ class Command(BaseCommand):
|
||||||
model registration. WARNING: buildwatson must be rerun if the filter \
|
model registration. WARNING: buildwatson must be rerun if the filter \
|
||||||
changes or the index will be incomplete."
|
changes or the index will be incomplete."
|
||||||
)
|
)
|
||||||
|
|
||||||
@transaction.atomic()
|
@transaction.atomic()
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
"""Runs the management command."""
|
"""Runs the management command."""
|
||||||
|
|
Loading…
Reference in New Issue