Delete Document from AWS CloudSearch
Asked Answered
C

2

6

I am attempting to delete a single document in AWS CloudSearch using the following batch document:

[{
    "type": "delete",
    "id": "532177"
}]

but I get the following error from AWS: enter image description here

and when download the SDF it returns the following:

[
{
type: "add",
id: "delete_img_json",
version: 1406072053,
lang: "en",
fields: {
content: "[{ "type": "delete", "id": "532177" }]",
resourcename: "Delete_IMG.json",
content_encoding: "ISO-8859-2",
content_type: "application/json"
}
}
]

All I am attempting to do is remove a single document from my CloudSearch index.

Chaldron answered 22/7, 2014 at 23:37 Comment(0)
G
12

I get the same error as you when I try to upload a single document that is not part of a batch:

{
    "type": "delete",
    "id": "4e41b5a6f3d94aa4891ab8f9abca94e6"
}

But it succeeds if it's part of a batch:

[{
    "type": "delete",
    "id": "4e41b5a6f3d94aa4891ab8f9abca94e6"
}]

I realize that you show a json array in your example above, but it is worth double-checking since you're getting the exact same error you'd get when trying to post a single document that is not part of an array. It would be an easy mistake to make since their own documentation on preparing data for submission shows a partial example where the delete is not part of an array (see the "To delete a document from a search domain" section).

Guardafui answered 24/7, 2014 at 20:35 Comment(1)
just wanted to add that amazon now requires a Version field for the delete to work.Otter
W
2

you can use simple xml file. (file extension should .XML)

<batch>
    <delete id="4e41b5a6f3d94aa4891ab8f9abca94e6" />
</batch>
Wheelock answered 8/7, 2016 at 7:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.