Skip to content

Commit 6696cad

Browse files
authored
Fix fill index bug (#2204)
* fix navitia coverage not indexed in elastic * fix linter * try fix tests * another fix..
1 parent a8566af commit 6696cad

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

c2corg_api/scripts/es/fill_index.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ def progress(count, total_count):
7676
count = 0
7777
with batch:
7878
for doc_type in document_types:
79-
print('Importing document type {}'.format(doc_type))
79+
if doc_type not in search_documents:
80+
# some document types (e.g. coverages) are not indexed
81+
logging.warning(
82+
'Document type {} is not indexed'.format(doc_type))
83+
continue
84+
85+
logging.info('Importing document type {}'.format(doc_type))
8086
to_search_document = search_documents[doc_type].to_search_document
8187

8288
for doc in sync.get_documents(session, doc_type, batch_size,

c2corg_api/scripts/es/sync.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,11 @@ def sync_documents(session, changed_documents, batch_size):
279279
docs_per_type = get_documents_per_type(changed_documents)
280280
add_dependent_documents(session, docs_per_type)
281281
for doc_type, document_ids in docs_per_type.items():
282+
if doc_type not in search_documents:
283+
# some document types (e.g. coverages) are not indexed
284+
logging.warning(
285+
'Document type {} is not indexed'.format(doc_type))
286+
continue
282287
if document_ids:
283288
docs = get_documents(
284289
session, doc_type, batch_size, document_ids)

c2corg_api/views/search.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@
2222
from c2corg_api.views.validation import validate_pagination, \
2323
validate_preferred_lang_param
2424
from c2corg_api.views.waypoint import waypoint_documents_config
25+
from c2corg_api.security.acl import ACLDefault
2526
from cornice.resource import resource, view
2627

2728

2829
@resource(path='/search', cors_policy=cors_policy)
29-
class SearchRest(object):
30-
def __init__(self, request):
31-
self.request = request
32-
30+
class SearchRest(ACLDefault):
3331
@view(validators=[validate_pagination, validate_preferred_lang_param])
3432
def get(self):
3533
"""Search for a query word (simple search).

0 commit comments

Comments
 (0)