Re: Help! Confused about using Jquery for the Search query - Want to ditch it
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 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. >
RE: Help! Confused about using Jquery for the Search query - Want to ditch it
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.
RE: Help! Confused about using Jquery for the Search query - Want to ditch it
As far as I know, it is the only way to do this. Look around a bit, Python (or PHP, or C, etc., etc.) is able to act as an HTTP client...in fact, that is the most common way that web services are consumed. But, we are definitely beyond the scope of the Solr list at this point. -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.
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.
RE: Help! Confused about using Jquery for the Search query - Want to ditch it
Yes (or, at least, I think I understand what you are saying, haha.) Let me clarify. 1. Client sends GET request to web server 2. Web server (via Python, in your case, if I remember correctly) queries Solr Server 3. Solr server sends response to web server 4. You take that data and put it into the page you are creating server-side 5. Server returns static page to client -Original Message- From: Spadez [mailto:james_will...@hotmail.com] Sent: Thursday, June 07, 2012 12:53 PM To: solr-user@lucene.apache.org Subject: RE: Help! Confused about using Jquery for the Search query - Want to ditch it Hi Ben, Thank you for the reply. So, If I don't want to use Javascript and I want the entire page to reload each time, is it being done like this? 1. User submits form via GET 2. Solr server queried via GET 3. Solr server completes query 4. Solr server returns XML output 5. XML data put into results page 6. User shown new results page Is this basically how it would work if we wanted Javascript out of the equation? Regards, James -- View this message in context: http://lucene.472066.n3.nabble.com/Help-Confused-about-using-Jquery-for-the-Search-query-Want-to-ditch-it-tp3988123p3988272.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.
Re: Help! Confused about using Jquery for the Search query - Want to ditch it
+1 on that! If you do want to provide direct results, ALWAYS send requests through a proxy that can verify that a) all requests are coming from your web app, and b) only "acceptable" queries are being passed on. Nick On 6/7/2012 2:50 PM, Michael Della Bitta wrote: On Thu, Jun 7, 2012 at 1:59 PM, Nick Chase wrote: The other option is to create a python page that does the call to Solr and spits out just the HTML for your results, then call THAT rather than calling Solr directly. This is the *only* option if you're listening to Walter and I. Don't give end users direct access to your Solr box!
Re: Help! Confused about using Jquery for the Search query - Want to ditch it
On Thu, Jun 7, 2012 at 1:59 PM, Nick Chase wrote: > The other option is to create a python page that does the call to Solr and > spits out just the HTML for your results, then call THAT rather than calling > Solr directly. This is the *only* option if you're listening to Walter and I. Don't give end users direct access to your Solr box! Michael Della Bitta Appinions, Inc. -- Where Influence Isn’t a Game. http://www.appinions.com
Re: Help! Confused about using Jquery for the Search query - Want to ditch it
On 6/7/2012 1:53 PM, Spadez wrote: Hi Ben, Thank you for the reply. So, If I don't want to use Javascript and I want the entire page to reload each time, is it being done like this? 1. User submits form via GET 2. Solr server queried via GET 3. Solr server completes query 4. Solr server returns XML output 5. XML data put into results page 6. User shown new results page Is this basically how it would work if we wanted Javascript out of the equation? Seems to me that you'd still have to have Javascript turn the XML into HTML -- unless you use the XsltResponseWriter (http://wiki.apache.org/solr/XsltResponseWriter) to use XSLT to turn the raw XML into your actual results HTML. The other option is to create a python page that does the call to Solr and spits out just the HTML for your results, then call THAT rather than calling Solr directly. Nick
RE: Help! Confused about using Jquery for the Search query - Want to ditch it
Hi Ben, Thank you for the reply. So, If I don't want to use Javascript and I want the entire page to reload each time, is it being done like this? 1. User submits form via GET 2. Solr server queried via GET 3. Solr server completes query 4. Solr server returns XML output 5. XML data put into results page 6. User shown new results page Is this basically how it would work if we wanted Javascript out of the equation? Regards, James -- View this message in context: http://lucene.472066.n3.nabble.com/Help-Confused-about-using-Jquery-for-the-Search-query-Want-to-ditch-it-tp3988123p3988272.html Sent from the Solr - User mailing list archive at Nabble.com.
RE: Help! Confused about using Jquery for the Search query - Want to ditch it
I'm new to Solr...but this is more of a web programming question...so I can get in on this :). Your only option to get the data from Solr sans-Javascript, is the use python to pull the results BEFORE the client loads the page. So, if you are asking if you can get AJAX like results (an already loaded page pulling info from your Solr server)...but without using Javascript...no, you cannot do that. You might be able to hack something ugly together using iframes, but trust me, you don't want to. It will look bad, it won't work well, and interacting with data in an iframe is nightmarish. So, basically, if you don't want to use Javascript, your only option is a total page reload every time you need to query Solr (which you then query on the python side.) -Original Message- From: Spadez [mailto:james_will...@hotmail.com] Sent: Thursday, June 07, 2012 11:37 AM To: solr-user@lucene.apache.org Subject: Re: Help! Confused about using Jquery for the Search query - Want to ditch it Thank you for the reply, but I'm afraid I don't understand :( This is how things are setup. On my Python website, I have a keyword and location box. When clicked, it queries the server via a javascript "GET" request, it then sends back the data via Json. I'm saying that I dont want to be reliant on Javascript. So I'm confused about the best way to not only send the request to the Solr server, but also how to receive the data. My guess is that a "GET" request without javascript is the right way to send the request to the Solr server, but then what should Solr be spitting out the other end, just an XML file? Then is the idea that my Python site would receive this XML data and display it on the site? -- View this message in context: http://lucene.472066.n3.nabble.com/Help-Confused-about-using-Jquery-for-the-Search-query-Want-to-ditch-it-tp3988123p3988246.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.
Re: Help! Confused about using Jquery for the Search query - Want to ditch it
Thank you for the reply, but I'm afraid I don't understand :( This is how things are setup. On my Python website, I have a keyword and location box. When clicked, it queries the server via a javascript "GET" request, it then sends back the data via Json. I'm saying that I dont want to be reliant on Javascript. So I'm confused about the best way to not only send the request to the Solr server, but also how to receive the data. My guess is that a "GET" request without javascript is the right way to send the request to the Solr server, but then what should Solr be spitting out the other end, just an XML file? Then is the idea that my Python site would receive this XML data and display it on the site? -- View this message in context: http://lucene.472066.n3.nabble.com/Help-Confused-about-using-Jquery-for-the-Search-query-Want-to-ditch-it-tp3988123p3988246.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: Help! Confused about using Jquery for the Search query - Want to ditch it
And keep Solr behind a firewall or authentication or even better, both! People *will* find and exploit your Solr installation. Michael Della Bitta Appinions, Inc. -- Where Influence Isn’t a Game. http://www.appinions.com On Thu, Jun 7, 2012 at 10:31 AM, Walter Underwood wrote: > This is a bad idea. Solr is not designed to be exposed to arbitrary internet > traffic and attacks. The best design is to have a front end server make > requests to Solr, then use those to make HTML pages. > > wunder > > On Jun 7, 2012, at 4:49 AM, Spadez wrote: > >> Final comment from me then Ill let someone else speak. >> >> The solution we seem to be looking at is send a GET request to SOLR and then >> send back a renderized page, so we are basically creating the results page >> on the server rather than the client side. >> >> I would really like to hear what people have to say about this. Is this a >> good idea? Are there any major disadvantages? >> >> It seems like the only way to go to have a reliable search site which works >> without Javascript. >> >> -- >> View this message in context: >> http://lucene.472066.n3.nabble.com/Help-Confused-about-using-Jquery-for-the-Search-query-Want-to-ditch-it-tp3988123p3988158.html >> Sent from the Solr - User mailing list archive at Nabble.com. > > > >
Re: Help! Confused about using Jquery for the Search query - Want to ditch it
This is a bad idea. Solr is not designed to be exposed to arbitrary internet traffic and attacks. The best design is to have a front end server make requests to Solr, then use those to make HTML pages. wunder On Jun 7, 2012, at 4:49 AM, Spadez wrote: > Final comment from me then Ill let someone else speak. > > The solution we seem to be looking at is send a GET request to SOLR and then > send back a renderized page, so we are basically creating the results page > on the server rather than the client side. > > I would really like to hear what people have to say about this. Is this a > good idea? Are there any major disadvantages? > > It seems like the only way to go to have a reliable search site which works > without Javascript. > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Help-Confused-about-using-Jquery-for-the-Search-query-Want-to-ditch-it-tp3988123p3988158.html > Sent from the Solr - User mailing list archive at Nabble.com.
Re: Help! Confused about using Jquery for the Search query - Want to ditch it
Final comment from me then Ill let someone else speak. The solution we seem to be looking at is send a GET request to SOLR and then send back a renderized page, so we are basically creating the results page on the server rather than the client side. I would really like to hear what people have to say about this. Is this a good idea? Are there any major disadvantages? It seems like the only way to go to have a reliable search site which works without Javascript. -- View this message in context: http://lucene.472066.n3.nabble.com/Help-Confused-about-using-Jquery-for-the-Search-query-Want-to-ditch-it-tp3988123p3988158.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: Help! Confused about using Jquery for the Search query - Want to ditch it
Further to my last reply. How about I do the following: Send the request to the server using the GET method and then return the results in XML rather than JSON. Does this sound logical? -- View this message in context: http://lucene.472066.n3.nabble.com/Help-Confused-about-using-Jquery-for-the-Search-query-Want-to-ditch-it-tp3988123p3988128.html Sent from the Solr - User mailing list archive at Nabble.com.
Help! Confused about using Jquery for the Search query - Want to ditch it
Hi, My current method of searching involes communicating to solr using python. The clients browser communicates to the search API using jquery/json. However, although this works, I dont like the dependancy on Javascript. Either I can keep with this method and have a backup system in place that works when javascript is disabled, or better yet, I can use a system that works both with Javascript or without. So I was thinking, instead of using the API and returning a JSON to be interpreted by Javascript, I could create a new handler to render the search results in the server and use POST to submit the query to the server. So, if I wanted a fast and effiicent method of querying results from Solr and returning the results all without Javascript enabled, what choices do I have? Your thoughts would be hugely appreciated because im new to this stuff. James -- View this message in context: http://lucene.472066.n3.nabble.com/Help-Confused-about-using-Jquery-for-the-Search-query-Want-to-ditch-it-tp3988123.html Sent from the Solr - User mailing list archive at Nabble.com.