Solr删除语句错误

时间:2012-07-30 06:47:13

标签: curl solr

我正在尝试solr ...尝试删除查询时出现以下错误:

 curl http://localhost:8983/solr/update --data-binary '<delete><id>SP2514N</id></delete>'

错误是:

Error 400 missing content stream  
Problem accessing /solr/update. Reason: missing content stream

2 个答案:

答案 0 :(得分:4)

另一个答案似乎是正确的,但没有解释原因。 您只需将您正在使用的内容类型更改为text/xml,否则curl会使用默认application/x-www-form-urlencoded--data-binary选项(或-d)。

您应该使用以下命令:

curl -H 'Content-Type: text/xml' http://localhost:8983/solr/update --data-binary '<delete><id>SP2514N</id></delete>'

您可能希望将commit=true参数添加到网址以立即发出提交,否则您仍会看到要删除的文档(直到下一次提交)。

您还可以使用stream.body参数直接在网址via GET中传递xml,就像在其他答案中建议的那样。

答案 1 :(得分:0)

使用: -

http://localhost:8983/solr/update?stream.body=<delete><query>id:SP2514N</query></delete>&commit=true