def get_object_source(source_id, object_id): index_name = '%s_%s' % (current_app.config['DEFAULT_INDEX_PREFIX'], source_id) try: obj = current_app.es.get(index=index_name, id=object_id, _source_include=['source_data']) except NotFoundError, e: if e.error.startswith('IndexMissingException'): message = 'Source \'%s\' does not exist' % source_id else: message = 'Document not found.' raise OcdApiError(message, 404)