ソースを参照

Test: assert adjacency matrix cache (#69440)

Adds an assertion that the adjacency matrix aggregation can hit the
request cache even when the request contains a lookup style `terms`
filter.
Nik Everett 4 年 前
コミット
b4bac7b769

+ 52 - 3
rest-api-spec/src/yamlRestTest/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,43 @@ 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: { 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:
+      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: { indices.test.total.request_cache.hit_count: 1 }
+  - match: { indices.test.total.request_cache.miss_count: 1 }