From c0d4a8581eb5f88d6e430ec72415db50b5645b62 Mon Sep 17 00:00:00 2001 From: Andy Wick Date: Mon, 5 Aug 2024 11:57:23 -0400 Subject: [PATCH] Added rest_total_hits_as_int test for _search (#466) * Added rest_total_hits_as_int test for _search Signed-off-by: Andy Wick * change request_body to request Signed-off-by: Andy Wick * Not gonna fight the linter Signed-off-by: Andy Wick * Add "Refn" to .cspell and back to test Signed-off-by: Andy Wick --------- Signed-off-by: Andy Wick --- .cspell | 3 +- .../_core/search/rest_total_hits_as_int.yaml | 125 ++++++++++++++++++ 2 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 tests/_core/search/rest_total_hits_as_int.yaml diff --git a/.cspell b/.cspell index 80670e9b..080c3937 100644 --- a/.cspell +++ b/.cspell @@ -183,4 +183,5 @@ urldecode vectory whoamiprotected wordnet -Yrtsd \ No newline at end of file +Yrtsd +Refn diff --git a/tests/_core/search/rest_total_hits_as_int.yaml b/tests/_core/search/rest_total_hits_as_int.yaml new file mode 100644 index 00000000..1885bc28 --- /dev/null +++ b/tests/_core/search/rest_total_hits_as_int.yaml @@ -0,0 +1,125 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test search endpoint with rest_total_hits_as_int. +prologues: + - path: /movies/_doc + method: POST + parameters: + refresh: true + request: + payload: + director: Bennett Miller + title: Moneyball + year: 2011 + status: [201] + - path: /movies/_doc + method: POST + parameters: + refresh: true + request: + payload: + director: Nicolas Winding Refn + title: Drive + year: 2011 + status: [201] +epilogues: + - path: /movies + method: DELETE + status: [200, 404] +chapters: + - synopsis: Search with rest_total_hits_as_int=true. + path: /{index}/_search + parameters: + index: movies + rest_total_hits_as_int: true + method: POST + request: + payload: + query: + match_all: {} + response: + status: 200 + payload: + timed_out: false + hits: + total: 2 + max_score: 1 + hits: + - _index: movies + _score: 1 + _source: + director: Bennett Miller + title: Moneyball + year: 2011 + - _index: movies + _score: 1 + _source: + director: Nicolas Winding Refn + title: Drive + year: 2011 + - synopsis: Search with rest_total_hits_as_int=false. + path: /{index}/_search + parameters: + index: movies + rest_total_hits_as_int: false + method: POST + request: + payload: + query: + match_all: {} + response: + status: 200 + payload: + timed_out: false + hits: + total: + value: 2 + relation: eq + max_score: 1 + hits: + - _index: movies + _score: 1 + _source: + director: Bennett Miller + title: Moneyball + year: 2011 + - _index: movies + _score: 1 + _source: + director: Nicolas Winding Refn + title: Drive + year: 2011 + - synopsis: Search with rest_total_hits_as_int=false track_total_hits=1. + path: /{index}/_search + parameters: + index: movies + rest_total_hits_as_int: false + method: POST + request: + payload: + track_total_hits: 1 + query: + match_all: {} + response: + status: 200 + payload: + timed_out: false + hits: + total: + value: 1 + relation: gte + max_score: 1 + hits: + - _index: movies + _score: 1 + _source: + director: Bennett Miller + title: Moneyball + year: 2011 + - _index: movies + _score: 1 + _source: + director: Nicolas Winding Refn + title: Drive + year: 2011 +