Solr delete Index using cURL

两盒软妹~` 提交于 2020-01-15 12:47:07

问题


I'm trying to delete all records from Solr. I can do this in the browser by posting the following URL

http://localhost:8983/solr/update?stream.body=<delete><query>*:*</query></delete>

However I wish to do it using the commmand line. I've installed cURL and have tested that the command line understands curl commands. But when I issue the following command

curl http://localhost:8983/solr/update --data '<delete><query>*:*</query></delete>' -H 'Content-type:text/xml; charset=utf-8' 

I receive the error

< was unexpected at this time

I have tried various different variations using single or double quotes to wrap the xml in, but nothing seems to work. Can anybody shed any light?

Thanks in advance.


回答1:


Here is an example of how to delete a solr index with curl:

https://gist.github.com/nz/673027

For windows, check this out:

How to post XML data with cURL using cmd in windows 7?




回答2:


You missed to add the commit=true parameter.

Would be simpler in this way, all you have to do is an HTTP GET request.

curl "http://localhost:8983/solr/collection1/update?commit=true&stream.body=<delete><query>*:*</query></delete>"




回答3:


Try these parameters

commit=true -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'


来源:https://stackoverflow.com/questions/17752850/solr-delete-index-using-curl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!