Hi,
what you want to do is not that difficult, you can use json, eg.

    try:
        conn = urllib.urlopen(url, params)
        page = conn.read()
        rsp = simplejson.loads(page)
        conn.close()
        return rsp
    except Exception, e:
        log.error(str(e))
        log.error(page)
        raise e

but this way you are initiating connection each time, which is
expensive - it would be better to pool the connections

but as you can see, you can get json or xml either way

another option is to use solrpy

import solr
import urllib
# create a connection to a solr server
s = solr.SolrConnection('http://localhost:8984/solr')
s.select = solr.SearchHandler(s, '/invenio')

def search(query, kwargs=None, fields=['id'], qt='invenio'):

    # do a remote search in solr
    url_params = urllib.urlencode([(k, v) for k,v in kwargs.items() if
k not in ['_', 'req']])

    if 'rg' in kwargs and kwargs['rg']:
        rows = min(kwargs['rg'], 100) #inv maximum limit is 100
    else:
        rows = 25
    response = s.query(query, fields=fields, rows=rows, qt=qt,
inv_params=url_params)
    num_found = response.numFound
    q_time = response.header['QTime']
    #.... more and return

r


On Thu, Jun 7, 2012 at 3:16 PM, Ben Woods <bwo...@quincyinc.com> wrote:
> But, check out things like httplib2 and urllib2.
>
> -----Original Message-----
> From: Spadez [mailto:james_will...@hotmail.com]
> Sent: Thursday, June 07, 2012 2:09 PM
> To: solr-user@lucene.apache.org
> Subject: RE: Help! Confused about using Jquery for the Search query - Want to 
> ditch it
>
> Thank you, that helps. The bit I am still confused about how the server sends 
> the response to the server though. I get the impression that there are 
> different ways that this could be done, but is sending an XML response back 
> to the Python server the best way to do this?
>
>
>
> --
> View this message in context: 
> http://lucene.472066.n3.nabble.com/Help-Confused-about-using-Jquery-for-the-Search-query-Want-to-ditch-it-tp3988123p3988302.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
> Quincy and its subsidiaries do not discriminate in the sale of advertising in 
> any medium (broadcast, print, or internet), and will accept no advertising 
> which is placed with an intent to discriminate on the basis of race or 
> ethnicity.
>

Reply via email to