0

I am beginner to solr.i want to transfer the data from solr to python and i have found the pysolr library i have installed it but did'nt know how to use it. I have searched on google but did'nt find required answer

I want to ask how we can load data from solr to python and perform filtering,sorting and other operations

i have tried as:

from pysolr import Solr
conn = Solr('/localhost:8983/solr/sms_data/select?indent=on&q=customer_id:73614&rows=10&start=0&wt=json')

Now how can i read the data present in conn and perform other operations.

Saurabh
  • 21
  • 7

1 Answers1

1

Your example is the complete Solr query string. That's not how you use pysolr. From pysolr's README (adapter to your example):

# 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)

Further functionality can be added as parameters to the .search method, such as fq (you'll have to use the kwargs-style if you want to include parameters with . in them):

results = solr.search('customer_id:73614', fq='field:value')

# or

result = solr.search('*:*', **{
    'fl': 'content',
    'facet': 'true',
    'facet.field': 'field_name'
})   
MatsLindh
  • 49,529
  • 4
  • 53
  • 84