How to delete SOLR indexed data by query with curl?
-
13-04-2021 - |
Question
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?
La solution
You have to add query
tag.
<delete><query>(cartype:stationwagon)AND(color:blue)</query></delete>
Autres conseils
In this way would be easier: curl "http://46.231.77.98:7979/solr/collection/update/?commit=true&stream.body=<delete><query>(cartype:stationwagon)AND(color:blue)</query></delete>"
It's a simple GET
request and you have just to add the parameter stream.body=<delete><query>(cartype:stationwagon)AND(color:blue)</query></delete>
to the query string.
Using JSON instead of XML:
curl -g "http://localhost:8983/solr/$core/update" \
-H 'Content-Type: application/json' \
-d '{"delete":{"query":"field:value"}}'
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow