<commit_before>es = None
try:
    from elasticsearch import Elasticsearch, TransportError
    from utility.tools import ELASTICSEARCH_HOST, ELASTICSEARCH_PORT

    es = Elasticsearch([{
        "host": ELASTICSEARCH_HOST
        , "port": ELASTICSEARCH_PORT
    }]) if (ELASTICSEARCH_HOST and ELASTICSEARCH_PORT) else None
except:
    es = None

def get_user_by_unique_column(column_name, column_value):
    return get_item_by_unique_column(column_name, column_value, index="users", doc_type="local")

def save_user(user, user_id):
    es_save_data("users", "local", user, user_id)

def get_item_by_unique_column(column_name, column_value, index, doc_type):
    item_details = None
    try:
        response = es.search(
            index = index
            , doc_type = doc_type
            , body = { <commit_msg>Add check for elasticsearch<commit_after>es = None
try:
    from elasticsearch import Elasticsearch, TransportError
    from utility.tools import ELASTICSEARCH_HOST, ELASTICSEARCH_PORT

    es = Elasticsearch([{
        "host": ELASTICSEARCH_HOST
        , "port": ELASTICSEARCH_PORT
    }]) if (ELASTICSEARCH_HOST and ELASTICSEARCH_PORT) else None

    # Check if elasticsearch is running
    if not es.ping():
        es = None
except:
    es = None

def get_user_by_unique_column(column_name, column_value):
    return get_item_by_unique_column(column_name, column_value, index="users", doc_type="local")

def save_user(user, user_id):
    es_save_data("users", "local", user, user_id)

def get_item_by_unique_column(column_name, column_value, index, doc_type):
    item_details = None
    try:
        response = es.search(
            index = index
            , doc_type = doc_type
            , body = { 
{'fraction_non_alphanumeric': 0.08569774174869717, 'fraction_numerical': 0.0, 'mean_word_length': 3.5473684210526315, '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': '3504981', 'n_tokens_mistral': 557, 'n_tokens_neox': 557, 'n_words': 129}