Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I delete all documents from a Marqo index?

I have a ton of documents that have been vectorized poorly / are using an old multimodal_field_combination.

mappings={
    'combo_text_image': {
        "type": "multimodal_combination",
        "weights": {
            "name": 0.05,
            "description": 0.15,
            "image_url": 0.8
        }
    }
},

But I need to update to

mappings={
    'combo_text_image': {
        "type": "multimodal_combination",
        "weights": {
            "name": 0.2,
            "image_url": 0.8
        }
    }
},

I’ve realized that to do this in the same index, I should delete the documents and then reindex but I haven’t been able to find a mq.delete_all_documents() call. What’s the best way to do this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Here is a code snippet that would delete all documents from the index:

def empty_index(index_name):
    index = mq.index(index_name)
    res =  index.search(q = '', limit=400)
    while len(res['hits']) > 0:
        id_set = []
        for hit in res['hits']:
            id_set.append(hit['_id'])
        index.delete_documents(id_set)
        res = index.search(q = '', limit=400)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading