예제 #1
0
def save_long_gexf(topic, identifyDate, identifyWindow, identifyGexf):
    index_name = topic + '_gexffile'

    get_graph_mappings(index_name)

    bulk_action = []
    #action = {"index":{"_id":999}}
    source = json.dumps(identifyGexf)
    action = {
        #"index":{"_id":999},
        #"_source":{
        "name": str(identifyDate) + str(identifyWindow),
        "gexf": source,
        "date": str(identifyDate),
        "window": identifyWindow,
        #}
    }
    bulk_action.extend([
        action,
    ])
    print bulk_action
    auto_id = [
        str(i) for i in str(identifyDate) + str(identifyWindow) if i.isdigit()
    ]
    auto_id = ''.join(auto_id)
    #es.bulk(bulk_action, index=index_name, doc_type='text', timeout=600)
    es.index(index=index_name, doc_type='text', id=auto_id, body=action)
예제 #2
0
def save_attribute_dict(attribute_dict, graph_type):
    '''
    临时保存attribute_dict,所以不进行topic的唯一指定,使其每一次存储都会覆盖上一次的。
    '''
    #ssdb = SSDB(SSDB_HOST, SSDB_PORT)
    
    if graph_type == 'g':
        key = 'g_attribute_dict'
    elif graph_type == 'ds_g':
        key = 'ds_g_attribute_dict'
    print 'key:', key.encode('utf-8')
    value = json.dumps(attribute_dict)
    print type(value)
    get_graph_mappings(key)
    #print '!!!!!!!!!!!!', value
    gexf2es(key, value)

    #result = ssdb.request('set', [key, value])
   
    print time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())), key.encode('utf-8'), 'save success'
예제 #3
0
파일: bulk_insert.py 프로젝트: SwoJa/ruman
def save_long_gexf(topic, identifyDate, identifyWindow, identifyGexf):
	index_name = topic+'_gexffile'
	
	get_graph_mappings(index_name)
	
	bulk_action = []
	#action = {"index":{"_id":999}}
	source = json.dumps(identifyGexf)
	action = {
    			#"index":{"_id":999},
				#"_source":{
				"name":str(identifyDate)+str(identifyWindow),
				"gexf":source,
				"date":str(identifyDate),
				"window":identifyWindow,
				#}
			}
	bulk_action.extend([action,])
	print bulk_action
	auto_id = [str(i)for i in str(identifyDate)+str(identifyWindow) if i.isdigit()]
	auto_id = ''.join(auto_id)
	#es.bulk(bulk_action, index=index_name, doc_type='text', timeout=600)
	es.index(index=index_name, doc_type='text', id=auto_id, body=action)