From 9b918c33bff9387a5a85aff4b6f4201c03cd306f Mon Sep 17 00:00:00 2001 From: dblock Date: Tue, 3 Sep 2024 07:46:41 -0400 Subject: [PATCH] Added tests for /{index}/_delete_by_query. Signed-off-by: dblock --- tests/default/indices/delete_by_query.yaml | 55 ++++++++++++++++++++++ tests/default/indices/update_by_query.yaml | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tests/default/indices/delete_by_query.yaml diff --git a/tests/default/indices/delete_by_query.yaml b/tests/default/indices/delete_by_query.yaml new file mode 100644 index 000000000..b6c9c0a90 --- /dev/null +++ b/tests/default/indices/delete_by_query.yaml @@ -0,0 +1,55 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test deleting documents that match a query. +epilogues: + - path: /books + method: DELETE + status: [200, 404] +prologues: + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: books, _id: book_1392214}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 60} + - {create: {_index: books, _id: book_1392215}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 91} +chapters: + - synopsis: Delete documents in the index (full query term, script). + path: /{index}/_delete_by_query + method: POST + parameters: + index: books + request: + payload: + query: + term: + title: + _name: title + value: beauty + case_insensitive: true + boost: 1 + response: + status: 200 + payload: + total: 1 + deleted: 1 + - synopsis: Delete remaining documents in the index. + path: /{index}/_delete_by_query + method: POST + parameters: + index: books + refresh: true + conflicts: proceed + request: + payload: + query: + match_all: {} + response: + status: 200 + payload: + total: 2 + deleted: 1 \ No newline at end of file diff --git a/tests/default/indices/update_by_query.yaml b/tests/default/indices/update_by_query.yaml index 0ce1295d4..bb3194ffd 100644 --- a/tests/default/indices/update_by_query.yaml +++ b/tests/default/indices/update_by_query.yaml @@ -1,6 +1,6 @@ $schema: ../../../json_schemas/test_story.schema.yaml -description: Test reindex. +description: Test updating documents that match a query. epilogues: - path: /books method: DELETE