File tree 2 files changed +9
-3
lines changed
modules/elasticsearch/src/main/java/org/elasticsearch
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 27
27
import org .elasticsearch .rest .*;
28
28
import org .elasticsearch .util .guice .inject .Inject ;
29
29
import org .elasticsearch .util .settings .Settings ;
30
+ import org .elasticsearch .util .xcontent .XContentFactory ;
30
31
import org .elasticsearch .util .xcontent .builder .XContentBuilder ;
31
32
32
33
import java .io .IOException ;
@@ -87,7 +88,12 @@ public class RestGetAction extends BaseRestHandler {
87
88
builder .field ("_type" , response .type ());
88
89
builder .field ("_id" , response .id ());
89
90
if (response .source () != null ) {
90
- builder .rawField ("_source" , response .source ());
91
+ if (builder .contentType () == XContentFactory .xContentType (response .source ())) {
92
+ builder .rawField ("_source" , response .source ());
93
+ } else {
94
+ builder .field ("_source" );
95
+ builder .value (response .source ());
96
+ }
91
97
}
92
98
93
99
if (response .fields () != null && !response .fields ().isEmpty ()) {
Original file line number Diff line number Diff line change @@ -206,10 +206,10 @@ public void shard(SearchShardTarget target) {
206
206
builder .field ("_id" , id ());
207
207
if (source () != null ) {
208
208
if (XContentFactory .xContentType (source ()) == builder .contentType ()) {
209
+ builder .rawField ("_source" , source ());
210
+ } else {
209
211
builder .field ("_source" );
210
212
builder .value (source ());
211
- } else {
212
- builder .rawField ("_source" , source ());
213
213
}
214
214
}
215
215
if (fields != null && !fields .isEmpty ()) {
You can’t perform that action at this time.
0 commit comments