Hamish Downer
Hamish Downer

Reputation: 17087

sunburnt - how to see the generated query URL

I'm using sunburnt, a python library for talking to Solr. I'm getting some unexpected results and it would help me in debugging if I could see what query was being generated by sunburnt. So instead of doing:

result = query.execute()

I want to do something like

url = query.generate_url()

Is anything like this possible? Are there any hacks that can achieve the same effect?

Upvotes: 1

Views: 508

Answers (2)

SecretHelper
SecretHelper

Reputation: 1

What about adding a print statement like below (this code is from sunburnt 0.5, I think, but it should be very similar no matter what version you're using)?

def select(self, params):
    qs = urllib.urlencode(params)
    url = "%s?%s" % (self.select_url, qs)
    print url #This should spit out the solr url
    r, c = self.request(url)
    if r.status != 200:
        raise SolrError(r, c)
    return c

Upvotes: 0

Hamish Downer
Hamish Downer

Reputation: 17087

Found the answer by reading the sunburnt docs more closely. It doesn't get me the exact URL, but is near enough:

params_dict = query.params()

Upvotes: 4

Related Questions