Example #1
0
def get_attribute_name():
    attribute_name_list = []
    try:
        attribute_result = es_tag.search(index=attribute_index_name, doc_type=attribute_index_type, \
                                     body={'query':{'match_all':{}}})['hits']['hits']
    except Exception, e:
        raise e
Example #2
0
def get_attribute_name():
    attribute_name_list = []
    try:
        attribute_result = es_tag.search(index=attribute_index_name, doc_type=attribute_index_type, \
                                     body={'query':{'match_all':{}}})['hits']['hits']
    except Exception, e:
        raise e
def search_attribute(query_body, condition_num):
    item_list = []
    default_size = 100000
    if condition_num==0:
        try:
            result = es_tag.search(index=attribute_index_name, doc_type=attribute_index_type, \
                    body={'query':{'match_all':{}}, 'size':default_size})['hits']['hits']
        except Exception, e:
            raise e
Example #4
0
def search_attribute(query_body, condition_num):
    item_list = []
    default_size = 100000
    if condition_num == 0:
        try:
            result = es_tag.search(index=attribute_index_name, doc_type=attribute_index_type, \
                    body={'query':{'match_all':{}}, 'size':default_size})['hits']['hits']
        except Exception, e:
            raise e
Example #5
0
def get_attribute_name(submit_user):
    attribute_name_list = []
    try:
        query_body = {
            "query": {
                "wildcard": {
                    "user": '******' + submit_user + '*'
                }
            },
            "size": 100000
        }
        attribute_result = es_tag.search(index=attribute_index_name, doc_type=attribute_index_type, \
                                     body=query_body)['hits']['hits']
    except Exception, e:
        raise e
def get_attribute_name(submit_user):
    attribute_name_list = []
    try:
        query_body = {
            "query":{
                 "wildcard":{
                    "user": '******' + submit_user + '*'
                        }
                    
            },
            "size": 100000
        }
        attribute_result = es_tag.search(index=attribute_index_name, doc_type=attribute_index_type, \
                                     body=query_body)['hits']['hits']
    except Exception, e:
        raise e
                body={'properties':{submit_user_tag:{'type':'string', 'analyzer':'my_analyzer'}}}, ignore=400)
    return status

# use to search attribute table
def search_attribute(query_body, condition_num):
    item_list = []
    default_size = 100000
    if condition_num==0:
        try:
            result = es_tag.search(index=attribute_index_name, doc_type=attribute_index_type, \
                    body={'query':{'match_all':{}}, 'size':default_size})['hits']['hits']
        except Exception, e:
            raise e
    else:
        try:
            result = es_tag.search(index=attribute_index_name, doc_type=attribute_index_type, \
                    body={'query':{'bool':{'must':query_body}}, 'size':default_size})['hits']['hits']
        except Exception, e:
            raise e
    if result:
        for item in result:
            source = item['_source']
            item_list.append(source)
    print item_list
    return item_list

# use to change attribtue
def change_attribute(attribute_name, value, submit_user, state):
    id_attribute = "-".join([submit_user, attribute_name])
    status = False
    # identify the attribute_name is in ES - custom attribute
    try:
Example #8
0
    return status


# use to search attribute table
def search_attribute(query_body, condition_num):
    item_list = []
    default_size = 100000
    if condition_num == 0:
        try:
            result = es_tag.search(index=attribute_index_name, doc_type=attribute_index_type, \
                    body={'query':{'match_all':{}}, 'size':default_size})['hits']['hits']
        except Exception, e:
            raise e
    else:
        try:
            result = es_tag.search(index=attribute_index_name, doc_type=attribute_index_type, \
                    body={'query':{'bool':{'must':query_body}}, 'size':default_size})['hits']['hits']
        except Exception, e:
            raise e
    if result:
        for item in result:
            source = item['_source']
            item_list.append(source)
    return item_list


# use to change attribtue
def change_attribute(attribute_name, value, user, state):
    status = False
    # identify the attribute_name is in ES - custom attribute
    try:
        result = es_tag.get(index=attribute_index_name,