diff --git a/c2corg_api/scripts/es/fill_index.py b/c2corg_api/scripts/es/fill_index.py index 392ffb707..abae3263a 100644 --- a/c2corg_api/scripts/es/fill_index.py +++ b/c2corg_api/scripts/es/fill_index.py @@ -76,7 +76,13 @@ def progress(count, total_count): count = 0 with batch: for doc_type in document_types: - print('Importing document type {}'.format(doc_type)) + if doc_type not in search_documents: + # some document types (e.g. coverages) are not indexed + logging.warning( + 'Document type {} is not indexed'.format(doc_type)) + continue + + logging.info('Importing document type {}'.format(doc_type)) to_search_document = search_documents[doc_type].to_search_document for doc in sync.get_documents(session, doc_type, batch_size, diff --git a/c2corg_api/scripts/es/sync.py b/c2corg_api/scripts/es/sync.py index 8a84e21cc..26793204c 100644 --- a/c2corg_api/scripts/es/sync.py +++ b/c2corg_api/scripts/es/sync.py @@ -279,6 +279,11 @@ def sync_documents(session, changed_documents, batch_size): docs_per_type = get_documents_per_type(changed_documents) add_dependent_documents(session, docs_per_type) for doc_type, document_ids in docs_per_type.items(): + if doc_type not in search_documents: + # some document types (e.g. coverages) are not indexed + logging.warning( + 'Document type {} is not indexed'.format(doc_type)) + continue if document_ids: docs = get_documents( session, doc_type, batch_size, document_ids) diff --git a/c2corg_api/views/search.py b/c2corg_api/views/search.py index e3acea9cd..ddb1dbbbe 100644 --- a/c2corg_api/views/search.py +++ b/c2corg_api/views/search.py @@ -22,14 +22,12 @@ from c2corg_api.views.validation import validate_pagination, \ validate_preferred_lang_param from c2corg_api.views.waypoint import waypoint_documents_config +from c2corg_api.security.acl import ACLDefault from cornice.resource import resource, view @resource(path='/search', cors_policy=cors_policy) -class SearchRest(object): - def __init__(self, request): - self.request = request - +class SearchRest(ACLDefault): @view(validators=[validate_pagination, validate_preferred_lang_param]) def get(self): """Search for a query word (simple search).