How to delete a document in Fusion via API

You can delete documents from Fusion using the Index Pipeline API.

 For example: Say you have a document with id = 1234 which you would like to delete from Fusion. You can use any of the following 2 commands to delete the document in Fusion via API.

 Note: Authentication passwords and collection names are required in the API request.

 1)  curl -u username:password -X POST -H "Content-Type: application/vnd.lucidworks-document" -d '[{

     "id": "1234","commands": [{"name": "delete","params": {}},{"name": "commit","params": {}}]}]'       http://localhost:8764/api/apollo/index-pipelines/index_pipeline_id/collections/collectionname/index

 OR

2)  http://localhost:8764/api/apollo/solr/collectionname/update?stream.body=<delete><query>id:"1234"</query></delete>&commit=true

 

 

 

 

 

Gitanjali Palwe

Search engineer

Lucidworks

Have more questions? Submit a request

2 Comments

  • 1
    Avatar
    Mark Bennett

    An excellent tech note Gitanjali, thanks!!!  I had heard rumors of something like method 1, but had no idea the exact syntax.

     

    Just a warning about Method 2: It requires direct, unfettered access to the Solr port.  People could also delete entire collections, etc.  Instead of "id:1234" they could do "*:*".  Sometimes this is exactly what an admin WANTS to do, for direct Solr collection maintenance, etc., I've even used it myself to cleanup cruft.  People should just be aware of it.

     

    I'd say Method 1 is generally preferred, because it uses the Fusion secured port, and Roles-based security.

  • 0
    Avatar
    Alexander Kanarsky

    In Method 2 the Fusion 'solr' endpoint is used (one that forwards requests to Solr), so the authorization is still in place, no direct access to Solr port. Also, one restriction here that worth to note - current Fusion implementation does not allow use of 'solr' endpoint with non-Fusion managed collections.

Please sign in to leave a comment.
Powered by Zendesk