# HG changeset patch
# User Samuel Trégouët <samuel.tregouet@logilab.fr>
# Date 1475073167 -7200
#      Wed Sep 28 16:32:47 2016 +0200
# Node ID 375fb06cb9b717f27bf77e23c66e8449f8a3ff40
# Parent  1390aeef7481b687d5502f3f0c1e35259747b5d4
ensure create_index is called on get_connection

diff --git a/entities.py b/entities.py
--- a/entities.py
+++ b/entities.py
@@ -61,6 +61,7 @@
     }
 
     def get_connection(self):
+        self.create_index()
         return es.get_connection(self._cw.vreg.config)
 
     def create_index(self, index_name=None, custom_settings=None):
@@ -71,7 +72,7 @@
             settings = {}
             deep_update(settings, self.settings)
             deep_update(settings, custom_settings)
-        es.create_index(self.get_connection(), index_name, settings)
+        es.create_index(es.get_connection(self._cw.vreg.config), index_name, settings)
 
 
 class IFullTextIndexSerializable(view.EntityAdapter):