in source/src/main/java/com/amazonaws/comprehend/esproxy/lambda/utils/RequestIdentifier.java [74:93]
public static Optional<String> getBulkIndexName(@NonNull String payloadLine) {
String payloadLineWithoutSpace = payloadLine.replaceAll(" +", "");
Optional<String> indexName = Optional.empty();
try {
JSONObject payloadJson = new JSONObject(payloadLineWithoutSpace);
if (payloadJson.has(Constants.BULK_INDEX_ACTION_KEY)) {
return Optional.ofNullable(payloadJson.getJSONObject(Constants.BULK_INDEX_ACTION_KEY)
.getString(Constants.BULK_INDEX_ACTION_KEY_NAME));
}
if (payloadJson.has(Constants.BULK_CREATE_ACTION_KEY)) {
return Optional.ofNullable(payloadJson.getJSONObject(Constants.BULK_CREATE_ACTION_KEY)
.getString(Constants.BULK_INDEX_ACTION_KEY_NAME));
}
// The payloadLine does not contain a index action
return indexName;
} catch (JSONException e) {
return indexName;
}
}