<commit_before>from dimagi.ext import jsonobject
from django.conf import settings
from copy import copy, deepcopy
from datetime import datetime
from elasticsearch import TransportError
from pillowtop import get_all_pillow_classes
from pillowtop.logger import pillow_logging

INDEX_REINDEX_SETTINGS = {
    "index": {
        "refresh_interval": "1800s",
        "merge.policy.merge_factor": 20,
        "store.throttle.max_bytes_per_sec": "1mb",
        "store.throttle.type": "merge",
        "number_of_replicas": "0"
    }
}

INDEX_STANDARD_SETTINGS = {
    "index": {
        "refresh_interval": "5s",
        "merge.policy.merge_factor": 10,
        "store.throttle.max_bytes_per_sec": "5mb",
        "store.throttle.type": "node",
        "number_of_replicas": "0"
    }
}


class ElasticsearchIndexInfo(jsonobject.JsonObject):
    index = jsonobject.StringProperty(required=True)
    alias = jsonobject.StringProperty()
    type = jsonobject.StringProperty()
    mapping = jsonobject.DictProperty()

    def __unicode__(self):
        return u'{} ({})'.format(self.alias, self.index)

    @property
    def meta(self):
        meta_settings = deepcopy(settings.ES_META['default'])
        meta_settings.update(
            settings.ES_META.get(self.alias, {})
        )
        meta_settings.update(<commit_msg>Removed 0 replicas from INDEX_SETTINGS.<commit_after>from dimagi.ext import jsonobject
from django.conf import settings
from copy import copy, deepcopy
from datetime import datetime
from elasticsearch import TransportError
from pillowtop import get_all_pillow_classes
from pillowtop.logger import pillow_logging

INDEX_REINDEX_SETTINGS = {
    "index": {
        "refresh_interval": "1800s",
        "merge.policy.merge_factor": 20,
        "store.throttle.max_bytes_per_sec": "1mb",
        "store.throttle.type": "merge",
    }
}

INDEX_STANDARD_SETTINGS = {
    "index": {
        "refresh_interval": "5s",
        "merge.policy.merge_factor": 10,
        "store.throttle.max_bytes_per_sec": "5mb",
        "store.throttle.type": "node",
    }
}


class ElasticsearchIndexInfo(jsonobject.JsonObject):
    index = jsonobject.StringProperty(required=True)
    alias = jsonobject.StringProperty()
    type = jsonobject.StringProperty()
    mapping = jsonobject.DictProperty()

    def __unicode__(self):
        return u'{} ({})'.format(self.alias, self.index)

    @property
    def meta(self):
        meta_settings = deepcopy(settings.ES_META['default'])
        meta_settings.update(
            settings.ES_META.get(self.alias, {})
        )
        meta_settings.update(
{'fraction_non_alphanumeric': 0.11372397841171936, 'fraction_numerical': 0.00963762528912876, 'mean_word_length': 3.3686868686868685, 'pattern_counts': {'":': 22, '<': 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': '121126', 'n_tokens_mistral': 821, 'n_tokens_neox': 802, 'n_words': 153}