Strinder
Strinder

Reputation: 2240

Delete all documents from Solr that have a certain empty field

Querying for those documents works with: "fq=-myfield:[* TO *]".

But how can I delete all those? It seems that the delete syntax update?stream.body=<delete><query>... accepts only a query, no filters...

Upvotes: 1

Views: 1815

Answers (2)

freedev
freedev

Reputation: 30067

The correct answer should be: -myfield:* or even -myfield:[* TO *], but the : is mandatory.

This is is an example with curl:

curl http://localhost:8983/solr/collection/update \ 
  -H "Content-Type: text/xml" \  
  --data-binary '<delete><query>-myfield:*</query></delete>'

Upvotes: 2

Saurabh Chaturvedi
Saurabh Chaturvedi

Reputation: 2156

Only pass -myfield[* TO *] in query tag. Do not pass fq parameter. Then it will work I feel. Once I had to delete all documents with id that contained word "data" in the id field string, I just passed id:*data* between query tags, and it worked. Let me know if that helps you.

Upvotes: 1

Related Questions