@@ -170,8 +170,8 @@ public IndexRequest(@Nullable ShardId shardId, StreamInput in) throws IOExceptio
170170 final int originalSourceSize ;
171171 if (in .getTransportVersion ().onOrAfter (TransportVersions .STRUCTURED_SOURCE )) {
172172 if (in .readBoolean ()) {
173- structuredSource = new ESONFlat (in );
174173 originalSourceSize = in .readVInt ();
174+ structuredSource = new ESONFlat (in );
175175 } else {
176176 BytesReference source = in .readBytesReference ();
177177 structuredSource = null ;
@@ -453,7 +453,8 @@ public ESONFlat structuredSource() {
453453 }
454454
455455 public Map <String , Object > sourceAsMap () {
456- return ESONIndexed .fromFlat (modernSource .structuredSource ());
456+ // TODO: Improve and remove need to do the bytes.
457+ return XContentHelper .convertToMap (modernSource .originalSourceBytes (), false , contentType ).v2 ();
457458 }
458459
459460 /**
@@ -805,8 +806,8 @@ private void writeBody(StreamOutput out) throws IOException {
805806 if (out .getTransportVersion ().onOrAfter (TransportVersions .STRUCTURED_SOURCE )) {
806807 out .writeBoolean (modernSource .isStructured ());
807808 if (modernSource .isStructured ()) {
808- ESONFlat structuredSource = modernSource .structuredSource ();
809809 out .writeVInt (modernSource .originalSourceSize ());
810+ ESONFlat structuredSource = modernSource .structuredSource ();
810811 out .writeBytesReference (structuredSource .getSerializedKeyBytes ());
811812 out .writeBytesReference (structuredSource .values ().data ());
812813 } else {
0 commit comments