Skip to content

Commit

Permalink
Index operations don't return _source in response
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolf committed May 5, 2020
1 parent 5935fe3 commit 9a41cd8
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,26 +403,23 @@ export class SavedObjectsRepository {
return expectedResult.error as any;
}

const {
requestedId,
rawMigratedDoc: {
_source: { type },
},
esRequestIndex,
} = expectedResult.value;
const { requestedId, rawMigratedDoc, esRequestIndex } = expectedResult.value;
const { error, ...rawResponse } = Object.values(
bulkResponse.items[esRequestIndex]
)[0] as any;

if (error) {
return {
id: requestedId,
type,
error: getBulkOperationError(error, type, requestedId),
type: rawMigratedDoc._source.type,
error: getBulkOperationError(error, rawMigratedDoc._source.type, requestedId),
};
}

return this._serializer.rawToSavedObject(rawResponse);
// When method == 'index' the bulkResponse doesn't include the indexed
// _source so we return rawMigratedDoc but have to spread rawResponse
// to return the latest _seq_no and _primary_term values from ES.
return this._serializer.rawToSavedObject({ ...rawMigratedDoc, ...rawResponse });
}),
};
}
Expand Down

0 comments on commit 9a41cd8

Please sign in to comment.