@@ -168,7 +168,8 @@ module SchemaDefinition
168168 s . object_type "MyType" do |t |
169169 t . field "id" , "ID"
170170 t . field "name" , "String"
171- t . field "legacy_count" , "Int" , graphql_only : true , name_in_index : "legacy_count_index" , returnable : false
171+ t . field "count" , "Int"
172+ t . field "legacy_count" , "Int" , graphql_only : true , name_in_index : "count" , returnable : false
172173 t . field "internal_count" , "Int" , indexing_only : true , returnable : false
173174 t . index "my_type"
174175 end
@@ -177,10 +178,10 @@ module SchemaDefinition
177178 expect ( mapping . dig ( "_source" , "excludes" ) ) . to contain_exactly ( "internal_count" )
178179 expect ( mapping . fetch ( "properties" ) ) . to include (
179180 "name" => { "type" => "keyword" } ,
181+ "count" => { "type" => "integer" } ,
180182 "internal_count" => { "type" => "integer" }
181183 )
182184 expect ( mapping . fetch ( "properties" ) ) . not_to include ( "legacy_count" )
183- expect ( mapping . fetch ( "properties" ) ) . not_to include ( "legacy_count_index" )
184185 end
185186
186187 it "uses full indexed paths in `_source.excludes` for `returnable: false` fields under nested mappings" do
@@ -215,6 +216,22 @@ module SchemaDefinition
215216 )
216217 end
217218
219+ it "excludes all descendants for non-highlightable `returnable: false` object fields" do
220+ mapping = index_mapping_for "my_type" do |s |
221+ s . object_type "InternalMetrics" do |t |
222+ t . field "count" , "Int"
223+ end
224+
225+ s . object_type "MyType" do |t |
226+ t . field "id" , "ID"
227+ t . field "internal_metrics" , "InternalMetrics" , returnable : false
228+ t . index "my_type"
229+ end
230+ end
231+
232+ expect ( mapping ) . to include ( "_source" => { "excludes" => [ "internal_metrics.*" ] } )
233+ expect ( mapping . dig ( "properties" , "internal_metrics" , "properties" , "count" ) ) . to eq ( { "type" => "integer" } )
234+ end
218235 it "does not include `_source` config when all fields are returnable" do
219236 mapping = index_mapping_for "my_type" do |s |
220237 s . object_type "MyType" do |t |
0 commit comments