Reputation: 2543
Trying to reset an index (delete all documents) via a POST request.
curl -X POST -H 'Content-Type: application/json' 'http://localhost:8983/solr/my_core/update?wt=json' --data-binary '
{
"delete": { "query":"*:*" }
}'
When there is an error, I don't get json string back in the body. Instead, I am getting html string
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /solr/my_core/update. Reason:
<pre> Not Found</pre></p>
</body>
</html>
Is there a way I can get the error expressed as json in the response body instead?
Thank you!
Upvotes: 0
Views: 273
Reputation: 789
The error response is HTML so that it will display correctly in a browser. In other words, it's human readable.
The response code -- HTTP code 404 -- is the only part of that error which is meant for machine consumption.
The format of the response will only be whatever was requested (json by default in recent Solr versions) if the request succeeds. This one didn't succeed.
Upvotes: 0
Reputation: 52832
The error message is telling you that the Solr installation and its core or handler wasn't found. The message is not generated as a result from your query; in that case it wouldn't be a 404. This is either created by having the wrong path (i.e. it's not /solr/
) , the requested core (/my_core/
), or the request handler (/update
) not being found.
You might be on Windows and using single quotes under cmd
- which will not do what you expect, and could up as part of the URL instead. Try with double quotes ("
) instead, and if that doesn't work, check that the URL works in your browser.
Upvotes: 1