solrpysolr

Pysolr filter search


I am using pysolr-2.0.15 api for Solr searching

mysite:8983/solr/select/?q=disease&fq=url:"pediatric"&version=2.2&start=0&rows=10&indent=on

This Solr query gives me successful result

I want to implement this using pysolr search function

I am trying this one:

results = conn.search('disease "url:Pediatric"')

But results are not correct.

Another problem is that the search method returns only 10 records; how can I get all search results.


Solution

  • You should pass the fq and rows as arguments:

    results = conn.search('disease', fq='url:Pediatric', rows=100)
    

    Note that you can pass multiple fq parameters:

    filter_queries = ['url:Pediatric', 'otherparam:othervalue']
    results = conn.search('disease', fq=filter_queries, rows=100)