python使用pysolr连接solr库

使用pysolr连接slor库时,出现以下错误

solr = pysolr.Solr('http://xxx.xxx.xxx.xxx:8080/solr/#/cnpatent/query', timeout=10)
dict = {'start':0, 'rows':10}
result = solr.search('name:my_name',**dict)
name = 'tyler'
date = '2020'
type = 3
'''
	#快速检索
	dict = {'start':0, 'rows':0,'facet':'on', 'facet.field':'***'}
	result = solr.search('name:%s AND date:%s AND NOT type:%d'%(name,date,type),**dict)
	#注意检索语句中AND和NOT需要大写,小写会出错
'''
for result in results:
	print(result['name'])
...raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

原因在于url出错,虽然使用上述url可以直接打开网页,但是此处需要删除一部分,正确url如下所示:

solr = pysolr.Solr('http://xxx.xxx.xxx.xxx:8080/solr/cnpatent', timeout=10)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值