@@ -84,6 +84,7 @@ public void testSearchQueryThenFetch() {
8484 "1"
8585 );
8686 assertMeasurements (List .of (QUERY_SEARCH_PHASE_METRIC , FETCH_SEARCH_PHASE_METRIC ));
87+ assertNotMeasured (List .of (CAN_MATCH_SEARCH_PHASE_METRIC , DFS_SEARCH_PHASE_METRIC , DFS_QUERY_SEARCH_PHASE_METRIC , OPEN_PIT_SEARCH_PHASE_METRIC ));
8788 }
8889
8990 public void testDfsSearch () {
@@ -92,10 +93,12 @@ public void testDfsSearch() {
9293 "1"
9394 );
9495 assertMeasurements (List .of (DFS_SEARCH_PHASE_METRIC , DFS_QUERY_SEARCH_PHASE_METRIC , FETCH_SEARCH_PHASE_METRIC ));
96+ assertNotMeasured (List .of (CAN_MATCH_SEARCH_PHASE_METRIC , QUERY_SEARCH_PHASE_METRIC , OPEN_PIT_SEARCH_PHASE_METRIC ));
9597 }
9698
9799 public void testPointInTime () {
98100 OpenPointInTimeRequest request = new OpenPointInTimeRequest (indexName ).keepAlive (TimeValue .timeValueMinutes (10 ));
101+ request .indexFilter (simpleQueryStringQuery ("doc1" ));
99102 OpenPointInTimeResponse response = client ().execute (TransportOpenPointInTimeAction .TYPE , request ).actionGet ();
100103 BytesReference pointInTimeId = response .getPointInTimeId ();
101104
@@ -108,6 +111,29 @@ public void testPointInTime() {
108111 "1"
109112 );
110113 assertMeasurements (List .of (OPEN_PIT_SEARCH_PHASE_METRIC , QUERY_SEARCH_PHASE_METRIC , FETCH_SEARCH_PHASE_METRIC ));
114+ assertNotMeasured (List .of (CAN_MATCH_SEARCH_PHASE_METRIC , DFS_SEARCH_PHASE_METRIC , DFS_QUERY_SEARCH_PHASE_METRIC ));
115+ } finally {
116+ client ().execute (TransportClosePointInTimeAction .TYPE , new ClosePointInTimeRequest (pointInTimeId )).actionGet ();
117+ }
118+ }
119+
120+ public void testPointInTimeWithPreFiltering () {
121+ OpenPointInTimeRequest request = new OpenPointInTimeRequest (indexName ).keepAlive (TimeValue .timeValueMinutes (10 ));
122+ request .indexFilter (simpleQueryStringQuery ("doc1" ));
123+ OpenPointInTimeResponse response = client ().execute (TransportOpenPointInTimeAction .TYPE , request ).actionGet ();
124+ BytesReference pointInTimeId = response .getPointInTimeId ();
125+
126+ try {
127+ assertSearchHitsWithoutFailures (
128+ client ().prepareSearch ()
129+ .setPointInTime (new PointInTimeBuilder (pointInTimeId ))
130+ .setSize (1 )
131+ .setPreFilterShardSize (1 )
132+ .setQuery (simpleQueryStringQuery ("doc1" )),
133+ "1"
134+ );
135+ assertMeasurements (List .of (OPEN_PIT_SEARCH_PHASE_METRIC , CAN_MATCH_SEARCH_PHASE_METRIC , QUERY_SEARCH_PHASE_METRIC , FETCH_SEARCH_PHASE_METRIC ));
136+ assertNotMeasured (List .of (DFS_SEARCH_PHASE_METRIC , DFS_QUERY_SEARCH_PHASE_METRIC ));
111137 } finally {
112138 client ().execute (TransportClosePointInTimeAction .TYPE , new ClosePointInTimeRequest (pointInTimeId )).actionGet ();
113139 }
@@ -123,6 +149,7 @@ public void testCanMatchSearch() {
123149 );
124150
125151 assertMeasurements (List .of (CAN_MATCH_SEARCH_PHASE_METRIC , FETCH_SEARCH_PHASE_METRIC , QUERY_SEARCH_PHASE_METRIC ));
152+ assertNotMeasured (List .of (DFS_SEARCH_PHASE_METRIC , DFS_QUERY_SEARCH_PHASE_METRIC , OPEN_PIT_SEARCH_PHASE_METRIC ));
126153 }
127154
128155 private void resetMeter () {
@@ -133,6 +160,13 @@ private TestTelemetryPlugin getTestTelemetryPlugin() {
133160 return getInstanceFromNode (PluginsService .class ).filterPlugins (TestTelemetryPlugin .class ).toList ().get (0 );
134161 }
135162
163+ private void assertNotMeasured (Collection <String > metricNames ) {
164+ for (var metricName : metricNames ) {
165+ List <Measurement > measurements = getTestTelemetryPlugin ().getLongHistogramMeasurement (metricName );
166+ assertThat (measurements , hasSize (0 ));
167+ }
168+ }
169+
136170 private void assertMeasurements (Collection <String > metricNames ) {
137171 for (var metricName : metricNames ) {
138172 List <Measurement > measurements = getTestTelemetryPlugin ().getLongHistogramMeasurement (metricName );
0 commit comments