--- a/src/pyams_content_es/site.py Sat Feb 17 15:58:52 2018 +0100
+++ b/src/pyams_content_es/site.py Sun Feb 18 12:43:46 2018 +0100
@@ -52,6 +52,11 @@
def site_index(request):
"""Index all site contents in ElasticSearch"""
+ registry = request.registry
+ es_client = getattr(registry, 'pyramid_es_client', None)
+ if es_client is None:
+ print("No Elasticsearch client defined. Aborting...")
+ return
application = site_factory(request)
if application is not None:
try:
@@ -60,7 +65,7 @@
if indexer is not None:
for document in find_objects_providing(application, IDocumentIndexTarget):
print("Indexing: {0!r}".format(document))
- indexer.index_document(document)
+ es_client.index_object(document)
finally:
set_local_registry(None)
transaction.commit()