Beispiel #1
0
 def start(self):
     context = zmq.Context()
     es_queue = context.socket(zmq.PUSH)
     es_queue.bind("tcp://127.0.0.1:5555")
     print "loading oplog...."
     for op,data,namespace in self.watch_oplog():
         if op == "i":
             document = es_data_mapping.remap(data)
             es_queue.send(dumps({"op":"index","data":document,"index":self.config["elasticsearch"]["index"],"doctype":namespace}))
         elif op == "d":
             #dont do this for now
             pass
def add(index,doctype,data):
    document = es_data_mapping.remap(data)
    es.index(document,index=index,doctype=doctype,bulk=True)