Python 2.6 Write, write your own blind, spare
"' Export and Import ElasticSearch Data. Simple Example at __main__ @author: wgzh159@163.com @note: Uncheck consistency of data, "Do It By" "Import j Sonimport osimport sysimport timeimport urllib2 Reload (SYS) sys.setdefaultencoding (' Utf-8 ') # @UndefinedVariable class Exportesdata (): size = 10000 def __init__ (self, url,index,type): Self.url = url+ "/" +index+ "/" +type+ "/_search" self . index = Index Self.type = Type def exportdata (self): print ("Export data begin ...") begin = Time.time () Try: Os.remove (self.index+ "_" +self.type+ ". JSON") Except:os.mknod (self.index+ "_" +self.type+ ". Json") msg = Urlli B2.urlopen (Self.url). Read () print (msg) obj = json.loads (msg) num = obj["hits" ["Total"] start = 0 end = num /self.size+1 while (start
The above mentioned is the whole content of this article, I hope you can like.