-1

I'm accessing the Retreive-And-Rank service using Python. So far I've uploaded my configuration and documents and have trained my ranker on the relevance file. All that is left, I presume, is to pass some query results (from Solr?) into the "rank" method of my R-A-R object.

My question: What exactly are those results, and what form do they come in? And how do I access them?

Right now I am accessing the PySolr object using the get_pysolr_client() method, then searching a query and using the returned results:

answer_data = pysolr.search(query)
rrv1.rank(<my_ranker_id>, answer_data, top_answers=10)

I'm doing this because it's analogous to what IBM does in the rank() method in the Java example. But I'm getting the error message:

AttributeError: 'Results' object has no attribute 'read'

I'm getting this because PySolr returns a "Results" object.

What should I be passing instead to the rank() method to get it to work?

The Retrieve_and_Rank specification for the rank method is as follows, and I think that answer_data is supposed to be a "file-like" object:

def rank(self, ranker_id, answer_data, top_answers=10)
ralphearle
  • 1,696
  • 13
  • 18
pythonian
  • 1
  • 1
  • 3

1 Answers1

0

One workaround is to call pysolr's _send_request method:

results = pysolr._send_request("GET", path="/fcselect?q=%s&ranker_id=%s&wt=json" %
                              (query_string, ranker_id))
for doc in json.loads(results)["response"]["docs"]:
    print doc

Thanks to rishavc on dW Answers for this.

pythonian
  • 1
  • 1
  • 3