arthur/writers.py
def create_mapping(idx_url, mapping):
        """Create a mapping"""

        mapping_url = idx_url + '/items/_mapping'
        mapping = json.dumps(mapping)

        try:
            r = requests.put(mapping_url, data=mapping,
                             headers={'Content-Type': 'application/json'})
        except requests.exceptions.ConnectionError:
            cause = "Error connecting to Elastic Search (index: %s, url: %s)" \
                % (idx_url, mapping_url)
            raise ElasticSearchError(cause=cause)

        if r.status_code != 200:
            reason = r.json()['error']
            logger.info("Can't create mapping in %s. %s",
                        mapping_url, reason)
            cause = "Error creating Elastic Search mapping %s. %s" % \
                (mapping_url, reason)
            raise ElasticSearchError(cause=cause)
        else:
            logger.info("Mapping created in %s", mapping_url)
def create_mapping(idx_url, mapping):
        """Create a mapping"""

        mapping_url = idx_url + '/items/_mapping'
        mapping = json.dumps(mapping)

        try:
            r = requests.put(mapping_url, data=mapping,
                             headers={'Content-Type': 'application/json'})
        except requests.exceptions.ConnectionError:
            cause = "Error connecting to Elastic Search (index: %s, url: %s)" \
                % (idx_url, mapping_url)
            raise ElasticSearchError(cause=cause)

        if r.status_code != 200:
            reason = r.json()['error']
            logger.info("Can't create mapping in %s. %s",
                        mapping_url, reason)
            cause = "Error creating Elastic Search mapping %s. %s" % \
                (mapping_url, reason)
            raise ElasticSearchError(cause=cause)
        else:
            logger.info("Mapping created in %s", mapping_url)
Create a mapping