将数据从solr传输到python

将数据从solr传输到python,python,solr,pysolr,Python,Solr,Pysolr,我是solr的初学者。我想将数据从solr传输到python,我找到了pysolr库,我已经安装了它,但不知道如何使用它。我在谷歌上搜索过,但没有找到需要的答案 我想问一下如何将数据从solr加载到python,并执行过滤、排序和其他操作 我试过: from pysolr import Solr conn = Solr('/localhost:8983/solr/sms_data/select?indent=on&q=customer_id:73614&rows=10&s

我是solr的初学者。我想将数据从solr传输到python,我找到了pysolr库,我已经安装了它,但不知道如何使用它。我在谷歌上搜索过,但没有找到需要的答案

我想问一下如何将数据从solr加载到python,并执行过滤、排序和其他操作

我试过:

from pysolr import Solr
conn = Solr('/localhost:8983/solr/sms_data/select?indent=on&q=customer_id:73614&rows=10&start=0&wt=json')
现在,我如何读取conn中的数据并执行其他操作。

您的示例是完整的Solr查询字符串。这不是你使用pysolr的方式。从pysolr的自述适配器到您的示例:

# Setup a Solr instance. 
solr = pysolr.Solr('http://localhost:8983/solr/sms_data')

results = solr.search('customer_id:73614')

for result in results:
    print(result)
进一步的功能可以作为参数添加到.search方法中,例如fq。如果要将参数包含在中,则必须使用kwargs样式。其中:


你试过什么?“你不明白的例子是什么?”MatsLindh我编辑过
results = solr.search('customer_id:73614', fq='field:value')

# or

result = solr.search('*:*', **{
    'fl': 'content',
    'facet': 'true',
    'facet.field': 'field_name'
})