您的位置:首页 > 其它

solrcloud 随机抽取中文搜索测试

2014-08-13 15:47 323 查看
#!/usr/bin/python
# -*- coding:utf-8 -*-
import solr
import pycurl
import cStringIO
import threading
import time
import os
import sys
import random
import urllib

def test(ip,value):
test_4=urllib.quote(value)
test_1='http://'+ip+'/solr/collection1/select?q=content:'+test_4+'&wt=json&indent=true'
#os.popen('curl %s'%test_1)
buf=cStringIO.StringIO()
c=pycurl.Curl()
c.setopt(c.URL,test_1)
c.setopt(c.WRITEFUNCTION,buf.write)
c.perform()
print buf.getvalue()
buf.close()

if __name__ == '__main__':
c=0
ss=sys.argv[1]
dict={'1':'排','2':'毒','3':'我','4':'有','5':'我','6':'选','7':'择','8':'之','9':'排','10':'毒','11':'方','12':'法','13':'知','14':'多','15':'少','16':'老','1
7':'年','18':'护','19':'理','20':'技','21':'术','22':'进','23':'出','24':'口','25':'业','26':'务','27':'发','28':'展','29':'与','30':'共','31':'享','32':'郑','33':'造'
,'34':'桓','35':'浙','36':'江','37':'大','38':'学','39':'出','40':'版','41':'社','42':'眼','43':'耳','44':'鼻','45':'咽','46':'喉','47':'护','48':'理','49':'许','50':'
建','51':'平','52':'律','53':'程','54':'序','55':'主','56':'义','57':'对','58':'预','59':'防','60':'行','61':'政','62':'的','63':'控','64':'制'}
while True:
for i in range(100):
list_1=[]
for kk in range(random.randint(1,5)):
ee=random.randint(1,64)
dd=dict[str(ee)]
list_1.append(dd)
value="".join(list_1)
print value

time_1=time.time()
print '++++'
a=threading.Thread(target=test,args=(ss,value))
a.start()
time_2=time.time()
d=time_2-time_1
print d
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  中文搜索