@@ -80,12 +80,19 @@ setup:
8080 fields :
8181 " object_field.nested_field " : {}
8282
83- # 1. Verify basic fetch profile structure
84- - is_true : profile.shards.0.fetch.0
83+ # 1. Verify fetch profile structure - should have main fetch + inner hits fetch
84+ - length : { profile.shards.0.fetch: 2 }
85+
86+ # Main fetch profile
8587 - match : { profile.shards.0.fetch.0.type: "fetch" }
8688 - match : { profile.shards.0.fetch.0.description: "fetch" }
8789 - is_true : profile.shards.0.fetch.0.time_in_nanos
8890
91+ # Inner hits fetch profile
92+ - match : { profile.shards.0.fetch.1.type: "fetch_inner_hits[object_field]" }
93+ - match : { profile.shards.0.fetch.1.description: "fetch_inner_hits[object_field]" }
94+ - is_true : profile.shards.0.fetch.1.time_in_nanos
95+
8996 # 2. Verify detailed breakdown of the main fetch operation
9097 - is_true : profile.shards.0.fetch.0.breakdown
9198 - is_true : profile.shards.0.fetch.0.breakdown.load_stored_fields
@@ -99,7 +106,20 @@ setup:
99106 - is_true : profile.shards.0.fetch.0.breakdown.create_stored_fields_visitor
100107 - match : { profile.shards.0.fetch.0.breakdown.create_stored_fields_visitor_count: 1}
101108
102- # 3. Verify all expected fetch sub-phases are present as children
109+ # 3. Verify inner hits fetch breakdown has all required fields (some may be 0)
110+ - is_true : profile.shards.0.fetch.1.breakdown
111+ - gte : { profile.shards.0.fetch.1.breakdown.load_stored_fields: 0 }
112+ - gte : { profile.shards.0.fetch.1.breakdown.load_stored_fields_count: 0 }
113+ - gte : { profile.shards.0.fetch.1.breakdown.load_source: 0 }
114+ - gte : { profile.shards.0.fetch.1.breakdown.load_source_count: 0 }
115+ - gte : { profile.shards.0.fetch.1.breakdown.get_next_reader: 0 }
116+ - match : { profile.shards.0.fetch.1.breakdown.get_next_reader_count: 1 }
117+ - gte : { profile.shards.0.fetch.1.breakdown.build_sub_phase_processors: 0 }
118+ - match : { profile.shards.0.fetch.1.breakdown.build_sub_phase_processors_count: 1 }
119+ - gte : { profile.shards.0.fetch.1.breakdown.create_stored_fields_visitor: 0 }
120+ - match : { profile.shards.0.fetch.1.breakdown.create_stored_fields_visitor_count: 1 }
121+
122+ # 4. Verify all expected fetch sub-phases are present as children in main fetch
103123 - length : { profile.shards.0.fetch.0.children: 9 }
104124 - contains :
105125 profile.shards.0.fetch.0.children :
@@ -129,6 +149,16 @@ setup:
129149 profile.shards.0.fetch.0.children :
130150 type : " FetchScorePhase"
131151
152+ # 5. Verify inner hits fetch has exactly 1 sub-phase (FetchSourcePhase)
153+ - length : { profile.shards.0.fetch.1.children: 1 }
154+ - match : { profile.shards.0.fetch.1.children.0.type: "FetchSourcePhase" }
155+ - is_true : profile.shards.0.fetch.1.children.0.time_in_nanos
156+ - is_true : profile.shards.0.fetch.1.children.0.breakdown
157+ - is_true : profile.shards.0.fetch.1.children.0.breakdown.process
158+ - gte : { profile.shards.0.fetch.1.children.0.breakdown.process_count: 1 }
159+ - is_true : profile.shards.0.fetch.1.children.0.breakdown.set_next_reader
160+ - match : { profile.shards.0.fetch.1.children.0.breakdown.set_next_reader_count: 1 }
161+
132162---
133163" No source or empty fetch profiling " :
134164 - skip :
@@ -171,6 +201,7 @@ setup:
171201 - skip :
172202 version : " - 3.1.99"
173203 reason : " Fetch phase profiling was introduced in 3.2.0"
204+ features : " contains"
174205
175206 - do :
176207 search :
@@ -181,13 +212,42 @@ setup:
181212 match :
182213 text_field : " document"
183214 aggs :
184- top_hits_agg :
215+ top_hits_agg1 :
216+ top_hits :
217+ size : 1
218+ top_hits_agg2 :
185219 top_hits :
186220 size : 1
221+ sort :
222+ - numeric_field : { order: desc }
223+
224+ - length : { profile.shards.0.fetch: 3 }
225+
226+ - contains :
227+ profile.shards.0.fetch :
228+ type : " fetch"
229+ description : " fetch"
230+
231+ - contains :
232+ profile.shards.0.fetch :
233+ type : " fetch_top_hits_aggregation[top_hits_agg1]"
234+ description : " fetch_top_hits_aggregation[top_hits_agg1]"
235+
236+ - contains :
237+ profile.shards.0.fetch :
238+ type : " fetch_top_hits_aggregation[top_hits_agg2]"
239+ description : " fetch_top_hits_aggregation[top_hits_agg2]"
240+
241+ - is_true : profile.shards.0.fetch.0.time_in_nanos
242+ - is_true : profile.shards.0.fetch.0.breakdown
243+ - is_true : profile.shards.0.fetch.1.time_in_nanos
244+ - is_true : profile.shards.0.fetch.1.breakdown
245+ - is_true : profile.shards.0.fetch.2.time_in_nanos
246+ - is_true : profile.shards.0.fetch.2.breakdown
187247
188- # Verify that the profile contains a single fetch operation for the query
189- - length : { profile.shards.0.fetch: 1 }
190- - match : { profile.shards.0.fetch.0.type: "fetch" }
191- - match : { profile.shards.0.fetch.0.description: "fetch" }
192248 - length : { profile.shards.0.fetch.0.children: 1 }
193249 - match : { profile.shards.0.fetch.0.children.0.type: "FetchSourcePhase" }
250+ - length : { profile.shards.0.fetch.1.children: 1 }
251+ - match : { profile.shards.0.fetch.1.children.0.type: "FetchSourcePhase" }
252+ - length : { profile.shards.0.fetch.2.children: 1 }
253+ - match : { profile.shards.0.fetch.2.children.0.type: "FetchSourcePhase" }
0 commit comments