Hi Dwane,

The error suggests that Solr is trying to add a document, rather than delete one, and is complaining that the DOC_ID is missing.

I tried each of your examples (without the smart quotes), and they all worked as expected, both from curl and the admin UI. There's an error in your longhand example, which should read
{ "delete": { "id": "123!12345" }}
However, even using your example, I didn't get a complaint about the field being missing.

Using curl, my command was:
curl -XPOST -H 'Content-type: application/json' http://localhost:8983/solr/testCollection/update -d '{ "delete": "123!12345" }'

Are you doing anything differently from that?

Thanks,
Matt


On 11/02/2019 23:24, Dwane Hall wrote:
Hey Solr community,

I’m having an issue deleting documents from my Solr index and am seeking some 
community advice when somebody gets a spare minute. It seems really like a 
really simple problem …a requirement to delete a document by its id.

Here’s how my documents are mapped in solr

<uniqueKey>DOC_ID</uniqueKey>
<field name="DOC_ID" type="string" indexed="true" stored="true" required="true" 
multiValued="false" />

My json format to delete the document (all looks correct according to 
https://lucene.apache.org/solr/guide/7_6/uploading-data-with-index-handlers.html
 “The JSON update format allows for a simple delete-by-id. The value of a 
delete can be an array which contains a list of zero or more specific document 
id’s (not a range) to be deleted. For example, a single document”)

Attempt 1 – “shorthand”
{“delete”:”123!12345”}

Attempt 2 – “longhand”
{“delete”:“DOC_ID”:”123!12345”}
{“delete”:{“DOC_ID”:”123!12345”}}

..the error is the same in all instances “org.apache.solr.common.SolrException: 
Document is missing mandatory uniqueKey field: DOC_ID”

Can anyone see any obvious details I’m overlooking?

I’ve tried all the update handlers below (both curl and through admin ui)

/update/
/update/json
/update/json/docs

My environment
Solr cloud 7.6
Single node

As always any advice would be greatly appreciated,

Thanks,

Dwane


--
Matt Pearce
Flax - Open Source Enterprise Search
www.flax.co.uk

Reply via email to