Thanks Matt, I was thinking the same regarding Solr thinking it's an update, not a delete. Sorry about the second "longhand" example, yes that was a copy paste issue the format is incorrect I was playing around with a few options with the JSON format. I'll keep testing the only difference I could see between our examples was you keeping your unique id field called "id" and not a custom value ("DOC_ID" in my instance). It seems minor but I've run out of any other ideas and am fishing at the moment.
Thanks again, Dwane ________________________________ From: Matt Pearce <m...@flax.co.uk> Sent: Wednesday, 13 February 2019 10:40 PM To: solr-user@lucene.apache.org Subject: Re: Delete by id 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<http://www.flax.co.uk>