23

I have a SOLR schema.xml like this:

<field name="cartype" type="lowercase" indexed="true" stored="true"/>
<field name="color" type="lowercase" indexed="true" stored="true"/>

I want to delete "blue" and "stationwagon" tagged records from SOLR database with a curl command.

But I didn't do that with following command :

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

Do you have any suggestions?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Guray Celik
  • 1,281
  • 1
  • 14
  • 13

3 Answers3

34

You have to add query tag.

<delete><query>(cartype:stationwagon)AND(color:blue)</query></delete>
robingrindrod
  • 474
  • 4
  • 18
Matej
  • 7,517
  • 2
  • 36
  • 45
6

Using JSON instead of XML:

curl -g "http://localhost:8983/solr/$core/update" \
     -H 'Content-Type: application/json' \
     -d '{"delete":{"query":"field:value"}}'
d-_-b
  • 21,536
  • 40
  • 150
  • 256
2

In this way would be easier:

curl -g "http://localhost:8983/solr/collection/update" \
     -d '<delete><query>(cartype:stationwagon)AND(color:blue)</query></delete>'

curl "http://localhost:8983/solr/collection/update?commit=true"

It's a simple POST request.

freedev
  • 25,946
  • 8
  • 108
  • 125