Example #1
0
 def get_document_resources(self):
     from app.api.document.facade import DocumentFacade
     return [] if self.obj.placenames_having_roles is None else [
         DocumentFacade(self.url_prefix, c.document,
                        self.with_relationships_links,
                        self.with_relationships_data).resource
         for c in self.obj.placenames_having_roles
     ]
Example #2
0
    def load_fixtures(self):
        from ..data.fixtures.dataset001 import load_fixtures as load_dataset001
        with self.app.app_context():
            from app import db
            load_dataset001(db)
            index_name = DocumentFacade.get_index_name()
            print("Reindexing", index_name)
            self.app.elasticsearch.indices.delete(index=index_name, ignore=[400, 404])  # remove all records

            from app.models import Document
            from app.api.search import SearchIndexManager
            for doc in Document.query.all():
                f_obj = DocumentFacade("", doc)
                for data in f_obj.get_data_to_index_when_added():
                    SearchIndexManager.add_to_index(index=index_name, id=doc.id, payload=data)