<commit_before>
''' ELS_Indexer class for WorkBench '''

class ELS_Indexer():

    def __init__(self, hosts=[{"host": "localhost", "port": 9200}]):

        # Get connection to ElasticSearch
        try:
            self.es = elasticsearch.Elasticsearch(hosts)
            print 'ELS Indexer connected: %s' % (str(hosts))
        except:
            print 'ELS connection failed! Is your ELS server running?'
            exit(1)

    def index_data(self, data, index_name='meta', doc_type='unknown'):

        # Index the data (which needs to be a dict/object) if it's not
        # we're going to toss an exception
        if not isinstance(data, dict):
            raise Exception('Index failed, data needs to be a dict!')

        try:
            self.es.index(index=index_name, doc_type=doc_type, body=data)
        except Exception, error:
            print 'Index failed: %s' % str(error)<commit_msg>just printing out additional information for the ELS server<commit_after>
''' ELS_Indexer class for WorkBench '''

class ELS_Indexer():

    def __init__(self, hosts=[{"host": "localhost", "port": 9200}]):

        # Get connection to ElasticSearch
        try:
            self.es = elasticsearch.Elasticsearch(hosts)
            info = self.es.info()
            version = info['version']
            print 'ELS Indexer connected: %s %s %s %s' % (str(hosts), info['name'], version['number'], version['lucene_version'])
        except:
            print 'ELS connection failed! Is your ELS server running?'
            exit(1)

    def index_data(self, data, index_name='meta', doc_type='unknown'):

        # Index the data (which needs to be a dict/object) if it's not
        # we're going to toss an exception
        if not isinstance(data, dict):
            raise Exception('Index failed, data needs to be a dict!')

        try:
            self.es.index(index=index_name, doc_type=doc_type, body=data)
        except Exception, error:
            print 'Index failed: %s' % str(error)
{'fraction_non_alphanumeric': 0.11494252873563218, 'fraction_numerical': 0.004997501249375313, 'mean_word_length': 2.543362831858407, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2603614', 'n_tokens_mistral': 586, 'n_tokens_neox': 561, 'n_words': 187}