def cmd_delete_doc(docid):
    """
    Arguments: <document_id>

    Delete a document.

    Possible JSON replies:
        --
        { "status": "ok", "docid": "xxxx" }
        --
        {
            "status": "error", "exception": "yyy",
            "reason": "xxxx", "args": "(xxxx, )"
        }
    """
    dsearch = get_docsearch()
    doc = dsearch.get(docid)
    if doc is None:
        raise Exception(
            "Document {} not found. Cannot delete it".format(
                docid
            )
        )
    index_updater = dsearch.get_index_updater(optimize=False)
    index_updater.del_doc(doc)
    index_updater.commit()
    doc.destroy()
    verbose("Document {} deleted".format(docid))
    reply({
        'docid': docid
    })
Arguments: <document_id>

    Delete a document.

    Possible JSON replies:
        --
        { "status": "ok", "docid": "xxxx" }
        --
        {
            "status": "error", "exception": "yyy",
            "reason": "xxxx", "args": "(xxxx, )"
        }