Hi,

If I request some query which is incorrect grammatically, error message is
shown in web browser but not in my python request code.
It just outputs "400 Bad Request".
How do I get error message in my python code?
Below is sample code...

-----------------------------------------------------------------------------------------
import ssl
import urllib

def request(url, params, headers={}, pass_verification=True):
    if pass_verification:
        context = ssl._create_unverified_context()
    else:
        context = None
    try:
        req = urllib.request.Request(url,
urllib.parse.urlencode(params).encode('utf-8'), headers)
        response = urllib.request.urlopen(req, context=context)
    except Exception as e:
        raise e
    return response.read()

request('http://localhost:8983/solr/select', params={'q':'(test AND AND
query)'})

-----------------------------------------------------------------------------------------

<response>
<lst name="responseHeader">
<int name="status">400</int>
<int name="QTime">72</int>
<lst name="params">
<str name="q">(test AND AND query)</str>
<str name="defType">lucene</str>
</lst>
</lst>
<lst name="error">
<str name="msg">
org.apache.solr.search.SyntaxError: Cannot parse '(test AND AND query)':
Encountered " <AND> "AND "" at line 1, column 10. Was expecting one of:
<NOT> ... "+" ... "-" ... <BAREOPER> ... "(" ... "*" ... <QUOTED> ... <TERM>
... <PREFIXTERM> ... <WILDTERM> ... <REGEXPTERM> ... "[" ... "{" ...
<LPARAMS> ... <NUMBER> ... <TERM> ... "*" ...
</str>
<int name="code">400</int>
</lst>
</response>



--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html

Reply via email to