当前位置: 首页 > 工具软件 > Pysolr > 使用案例 >

python使用pysolr连接solr库

易宣
2023-12-01

使用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)
 类似资料: