# Path: data_catalog/configuration_const.py
# METADATA_MAPPING = {
#     '_all': {
#         'enabled': False
#     },
#     'properties': {
#         'title': {
#             'type': 'string',
#             'analyzer': 'english'
#         },
#         'dataSample': {
#             'type': 'string'
#         },
#         'format': {
#             'type': 'string'
#         },
#         'category': {
#             'type': 'string'
#         },
#         'size': {
#             'type': 'long'
#         },
#         'recordCount': {
#             'type': 'long'
#         },
#         'sourceUri': {
#             'type': 'string',
#             'analyzer': 'uri_analyzer'
#         },
#         'targetUri': {
#             'type': 'string'
#         },
#         'storeType': {
#             'type': 'string'
#         },
#         'creationTime': {
#             'type': 'date'
#         },
#         'orgUUID': {
#             'type': 'string',
#             'index': 'not_analyzed'
#         },
#         'isPublic': {
#             'type': 'boolean'
#         }
#     }
# }
# METADATA_SETTINGS = {
#     'analysis': {
#         'filter': {
#             'uri_stop_filter': {
#                 'type': 'stop',
#                 'stopwords': ['http', 'https', 'ftp', 'www', 'com']
#             }
#         },
#         'analyzer': {
#             'uri_analyzer': {
#                 'type': 'custom',
#                 'tokenizer': 'lowercase',
#                 'filter': 'uri_stop_filter'
#             }
#         }
#     }
# }


import json
import os
from data_catalog import configuration_const
        :raises NoConfigEnvError: When VCAP_SERVICES is not present and the app can't run.
        """
        if not VCAP_SERVICES in os.environ:
            raise NoConfigEnvError(
                'VCAP_SERVICES environment variable needs to be set to run Data Catalog.')


class NoConfigEnvError(Exception):
    """
    Environment variable that should contain configuration is missing.
    """
    pass


class ElasticConfig(object):

    """
    Config for ElasticSearch connection.
    """

    def __init__(self, services_config):
        self.elastic_index = 'trustedanalytics-meta'
        self.elastic_metadata_type = 'dataset'
        self.elastic_categories_type = 'categories'

        self.metadata_index_setup = {
            'settings': {
                'index': configuration_const.METADATA_SETTINGS
            },
            'mappings': {

# Path: data_catalog/configuration_const.py
# METADATA_MAPPING = {
#     '_all': {
#         'enabled': False
#     },
#     'properties': {
#         'title': {
#             'type': 'string',
#             'analyzer': 'english'
#         },
#         'dataSample': {
#             'type': 'string'
#         },
#         'format': {
#             'type': 'string'
#         },
#         'category': {
#             'type': 'string'
#         },
#         'size': {
#             'type': 'long'
#         },
#         'recordCount': {
#             'type': 'long'
#         },
#         'sourceUri': {
#             'type': 'string',
#             'analyzer': 'uri_analyzer'
#         },
#         'targetUri': {
#             'type': 'string'
#         },
#         'storeType': {
#             'type': 'string'
#         },
#         'creationTime': {
#             'type': 'date'
#         },
#         'orgUUID': {
#             'type': 'string',
#             'index': 'not_analyzed'
#         },
#         'isPublic': {
#             'type': 'boolean'
#         }
#     }
# }
# METADATA_SETTINGS = {
#     'analysis': {
#         'filter': {
#             'uri_stop_filter': {
#                 'type': 'stop',
#                 'stopwords': ['http', 'https', 'ftp', 'www', 'com']
#             }
#         },
#         'analyzer': {
#             'uri_analyzer': {
#                 'type': 'custom',
#                 'tokenizer': 'lowercase',
#                 'filter': 'uri_stop_filter'
#             }
#         }
#     }
# }


# Path: data_catalog/configuration.py
import json
import os
from data_catalog import configuration_const

        :raises NoConfigEnvError: When VCAP_SERVICES is not present and the app can't run.
        """
        if not VCAP_SERVICES in os.environ:
            raise NoConfigEnvError(
                'VCAP_SERVICES environment variable needs to be set to run Data Catalog.')


class NoConfigEnvError(Exception):
    """
    Environment variable that should contain configuration is missing.
    """
    pass


class ElasticConfig(object):

    """
    Config for ElasticSearch connection.
    """

    def __init__(self, services_config):
        self.elastic_index = 'trustedanalytics-meta'
        self.elastic_metadata_type = 'dataset'
        self.elastic_categories_type = 'categories'

        self.metadata_index_setup = {
            'settings': {
                'index': configuration_const.METADATA_SETTINGS
            },
            'mappings': {

                self.elastic_metadata_type: configuration_const.METADATA_MAPPING