Issue
I am working with solr and python.I use urllib library to get http data.
I write code as:
from urllib2 import *
connection = urlopen('http://localhost:8983/solr/data/select?indent=on&q=sender_name:*AXI*&wt=json')
It was working fine but when I apply more query filter string as follows as:
from urllib2 import *
connection = urlopen('http://localhost:8983/solr/data/select?indent=on&q=sender_name:*AXI* AND message:*Avbl*&wt=json')
I got error as:
HTTPError Traceback (most recent call last)
<ipython-input-22-6dad7f9847f1> in <module>()
----> 1 connection = urlopen('http://localhost:8983/solr/data/select?indent=on&q=sender_name:*AXI* AND message:*Avbl*&wt=json')
/usr/lib/python2.7/urllib2.pyc in urlopen(url, data, timeout, cafile, capath, cadefault, context)
152 else:
153 opener = _opener
--> 154 return opener.open(url, data, timeout)
155
156 def install_opener(opener):
/usr/lib/python2.7/urllib2.pyc in open(self, fullurl, data, timeout)
433 for processor in self.process_response.get(protocol, []):
434 meth = getattr(processor, meth_name)
--> 435 response = meth(req, response)
436
437 return response
/usr/lib/python2.7/urllib2.pyc in http_response(self, request, response)
546 if not (200 <= code < 300):
547 response = self.parent.error(
--> 548 'http', request, response, code, msg, hdrs)
549
550 return response
/usr/lib/python2.7/urllib2.pyc in error(self, proto, *args)
471 if http_err:
472 args = (dict, 'default', 'http_error_default') + orig_args
--> 473 return self._call_chain(*args)
474
475 # XXX probably also want an abstract factory that knows when it makes
/usr/lib/python2.7/urllib2.pyc in _call_chain(self, chain, kind, meth_name, *args)
405 func = getattr(handler, meth_name)
406
--> 407 result = func(*args)
408 if result is not None:
409 return result
/usr/lib/python2.7/urllib2.pyc in http_error_default(self, req, fp, code, msg, hdrs)
554 class HTTPDefaultErrorHandler(BaseHandler):
555 def http_error_default(self, req, fp, code, msg, hdrs):
--> 556 raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
557
558 class HTTPRedirectHandler(BaseHandler):
HTTPError: HTTP Error 400: Unknown Version
How can this error be resolved.
Solution
An URL does not contain space characters. You can replace space characters with "%20" when it is a query.
Answered By - Amjad sibili
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.