✨(backend) add fallback search & default ordering
Filter deleted documents from visited ones. Set default ordering to the Find API search call (-updated_at) BaseDocumentIndexer.search now returns a list of document ids instead of models. Do not call the indexer in signals when SEARCH_INDEXER_CLASS is not defined or properly configured. Signed-off-by: Fabre Florian <ffabre@hybird.org>
This commit is contained in:
committed by
Quentin BEY
parent
bf978b5376
commit
01c31ddd74
@@ -2,10 +2,14 @@
|
||||
Declare and configure the signals for the impress core application
|
||||
"""
|
||||
|
||||
from functools import partial
|
||||
|
||||
from django.db import transaction
|
||||
from django.db.models import signals
|
||||
from django.dispatch import receiver
|
||||
|
||||
from . import models
|
||||
from .services.search_indexers import default_document_indexer
|
||||
from .tasks.find import trigger_document_indexer
|
||||
|
||||
|
||||
@@ -16,7 +20,8 @@ def document_post_save(sender, instance, **kwargs): # pylint: disable=unused-ar
|
||||
Note : Within the transaction we can have an empty content and a serialization
|
||||
error.
|
||||
"""
|
||||
trigger_document_indexer(instance, on_commit=True)
|
||||
if default_document_indexer() is not None:
|
||||
transaction.on_commit(partial(trigger_document_indexer, instance))
|
||||
|
||||
|
||||
@receiver(signals.post_save, sender=models.DocumentAccess)
|
||||
@@ -24,5 +29,5 @@ def document_access_post_save(sender, instance, created, **kwargs): # pylint: d
|
||||
"""
|
||||
Asynchronous call to the document indexer at the end of the transaction.
|
||||
"""
|
||||
if not created:
|
||||
trigger_document_indexer(instance.document, on_commit=True)
|
||||
if not created and default_document_indexer() is not None:
|
||||
transaction.on_commit(partial(trigger_document_indexer, instance.document))
|
||||
|
||||
Reference in New Issue
Block a user