Exemplo n.º 1
0
def save_key_edges_results(hash_tag, weak_link, future_edge):

    pinyin_hash_tag = pinyin.get(hash_tag, format="strip", delimiter="_")

    key_edges_es_mappings()

    index_name = 'key_edges_results'
    id = pinyin_hash_tag
    index_type = "edge"

    item = {}

    item['hash_tag'] = hash_tag
    item['retweet_rank'] = weak_link
    item['negtive_rank'] = future_edge

    try:
        item_exist = key_es.get(index=index_name, doc_type=index_type,
                                id=id)['_source']
        key_es.update(index=index_name,
                      doc_type=index_type,
                      id=id,
                      body={'doc': item})
    except Exception, e:
        # raise e
        key_es.index(index=index_name, doc_type=index_type, id=id, body=item)
Exemplo n.º 2
0
def save_key_nodes_results(hash_tag, fans_rank, negtive_rank, pagerank_rank,
                           sensitive_rank):
    print 'pinyin'
    print 'pinyin:', pinyin.get(hash_tag, format="strip", delimiter="_")
    pinyin_hash_tag = pinyin.get(hash_tag, format="strip", delimiter="_")

    key_nodes_es_mappings()

    index_name = 'key_nodes_results'
    id = pinyin_hash_tag
    index_type = "node"
    item = {}
    #id_time = time.ctime()
    item['hash_tag'] = hash_tag
    item['fans_rank'] = json.dumps(fans_rank)
    item['negtive_rank'] = str(negtive_rank)
    item['pagerank_rank'] = json.dumps(pagerank_rank)
    item['sensitive_rank'] = json.dumps(sensitive_rank)
    try:
        item_exist = key_es.get(index=index_name, doc_type=index_type,
                                id=id)['_source']
        key_es.update(index=index_name,
                      doc_type=index_type,
                      id=id,
                      body={'doc': item})
    except Exception, e:
        # raise e
        key_es.index(index=index_name, doc_type=index_type, id=id, body=item)
Exemplo n.º 3
0
def save_key_mblogs_results(hash_tag, retweet_rank, negtive_rank):

    pinyin_hash_tag = pinyin.get(hash_tag, format="strip", delimiter="_")

    key_mblogs_es_mappings()

    index_name = 'key_mblogs_results'
    id = pinyin_hash_tag
    index_type = "mblog"

    item = {}

    item['hash_tag'] = hash_tag
    item['retweet_rank'] = json.dumps(retweet_rank)
    item['negtive_rank'] = json.dumps(negtive_rank)

    try:
        item_exist = key_es.get(index=index_name, doc_type=index_type,
                                id=id)['_source']
        key_es.update(index=index_name,
                      doc_type=index_type,
                      id=id,
                      body={'doc': item})
    except Exception, e:
        # raise e
        key_es.index(index=index_name, doc_type=index_type, id=id, body=item)
Exemplo n.º 4
0
def save_info_max_results(hash_tag, info_max):

    pinyin_hash_tag = pinyin.get(hash_tag, format="strip", delimiter="_")

    info_max_es_mappings()

    index_name = 'info_max_results'
    id = pinyin_hash_tag
    index_type = "info_max"

    item = {}

    item['hash_tag'] = hash_tag
    item['info_max'] = info_max

    try:
        item_exist = key_es.get(index=index_name, doc_type=index_type,
                                id=id)['_source']
        key_es.update(index=index_name,
                      doc_type=index_type,
                      id=id,
                      body={'doc': item})
    except Exception, e:
        # raise e
        key_es.index(index=index_name, doc_type=index_type, id=id, body=item)