如何通过curl查询删除SOLR索引数据?

Gur*_*lik 19 schema curl solr http-delete

我有一个像这样的SOLR schema.xml:

<field name="cartype" type="lowercase" indexed="true" stored="true"/>
<field name="color" type="lowercase" indexed="true" stored="true"/>
Run Code Online (Sandbox Code Playgroud)

我想用curl命令从SOLR数据库中删除"blue"和"stationwagon"标记的记录.

但我没有用以下命令做到这一点:

curl http://46.231.77.98:7979/solr/update/?commit=true -H "Content-Type: text/xml" -d "<delete>(cartype:stationwagon)AND(color:blue)</delete>"
Run Code Online (Sandbox Code Playgroud)

你有什么建议吗?

Mat*_*tej 31

你必须添加query标签.

<delete><query>(cartype:stationwagon)AND(color:blue)</query></delete>
Run Code Online (Sandbox Code Playgroud)


d-_*_*_-b 7

使用 JSON 代替 XML:

curl -g "http://localhost:8983/solr/$core/update" \
     -H 'Content-Type: application/json' \
     -d '{"delete":{"query":"field:value"}}'
Run Code Online (Sandbox Code Playgroud)