From 848a3716ee5fc1846312ed1ace40a0be70e9ecc2 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 23 Feb 2021 09:11:57 -0500 Subject: [PATCH 1/2] Test: assert adjacency matrix cache Adds an assertion that the adjacency matrix aggregation can hit the request cache even when the request contains a lookup style `terms` filter. --- .../70_adjacency_matrix.yml | 57 ++++++++++++++++++- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/70_adjacency_matrix.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/70_adjacency_matrix.yml index a98f3501d0a86..0587c2ae11f44 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/70_adjacency_matrix.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/70_adjacency_matrix.yml @@ -23,8 +23,6 @@ setup: { "index": {"_id": "3"}} { "num": [3, 4] } - - do: - indices.refresh: {} --- "Filters intersections": @@ -69,7 +67,17 @@ setup: - skip: version: " - 7.8.99" reason: fixed in 7.9.0 - + - do: + indices.create: + index: lookup + body: + settings: + number_of_shards: 1 + number_of_replicas: 0 + mappings: + properties: + num: + type: long - do: bulk: index: lookup @@ -81,6 +89,7 @@ setup: { "num": [2] } { "index": {"_id": 4} } { "num": [4] } + - do: search: index: test @@ -124,3 +133,45 @@ setup: - match: { aggregations.conns.buckets.3.doc_count: 1 } - match: { aggregations.conns.buckets.3.key: "4" } + + - do: + indices.stats: { index: test, metric: request_cache} + - match: { _shards.total: 1 } + - match: { _all.total.request_cache.hit_count: 0 } + - match: { _all.total.request_cache.miss_count: 1 } + - is_true: indices.test + + # The second request should hit the cache + - do: + search: + index: test + body: + size: 0 + aggs: + conns: + adjacency_matrix: + filters: + 1: + terms: + num: + index: lookup + id: "1" + path: num + 2: + terms: + num: + index: lookup + id: "2" + path: num + 4: + terms: + num: + index: lookup + id: "4" + path: num + - do: + indices.stats: { index: test, metric: request_cache} + - match: { _shards.total: 1 } + - match: { _all.total.request_cache.hit_count: 1 } + - match: { _all.total.request_cache.miss_count: 1 } + - is_true: indices.test From eb6fa4401b27d60c3b9bab3d9b45f134b33ceee6 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 13 Apr 2021 16:14:21 -0400 Subject: [PATCH 2/2] Switch to exact stats --- .../test/search.aggregation/70_adjacency_matrix.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.aggregation/70_adjacency_matrix.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.aggregation/70_adjacency_matrix.yml index 0587c2ae11f44..e2c68a9455d0f 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.aggregation/70_adjacency_matrix.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.aggregation/70_adjacency_matrix.yml @@ -137,9 +137,8 @@ setup: - do: indices.stats: { index: test, metric: request_cache} - match: { _shards.total: 1 } - - match: { _all.total.request_cache.hit_count: 0 } - - match: { _all.total.request_cache.miss_count: 1 } - - is_true: indices.test + - match: { indices.test.total.request_cache.hit_count: 0 } + - match: { indices.test.total.request_cache.miss_count: 1 } # The second request should hit the cache - do: @@ -172,6 +171,5 @@ setup: - do: indices.stats: { index: test, metric: request_cache} - match: { _shards.total: 1 } - - match: { _all.total.request_cache.hit_count: 1 } - - match: { _all.total.request_cache.miss_count: 1 } - - is_true: indices.test + - match: { indices.test.total.request_cache.hit_count: 1 } + - match: { indices.test.total.request_cache.miss_count: 1 }