示例#1
0
def get_attribute_name():
    attribute_name_list = []
    try:
        attribute_result = es.search(index=attribute_index_name, doc_type=attribute_index_type, \
                                     body={'query':{'match_all':{}}})['hits']['hits']
    except Exception, e:
        raise e
示例#2
0
def search_attribute(query_body, condition_num):
    item_list = []
    default_size = 100000
    if condition_num==0:
        try:
            result = es.search(index=attribute_index_name, doc_type=attribute_index_type, \
                    body={'query':{'match_all':{}}, 'size':default_size})['hits']['hits']
        except Exception, e:
            raise e
示例#3
0
    print status
    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.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.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.get(index=attribute_index_name, doc_type=attribute_index_type, id=attribute_name)['_source']
    except: