*/
protected XContentBuilder prepareIssueIndexedDocument(String jiraProjectKey, Map<String, Object> issue)
throws Exception {
String issueKey = extractIssueKey(issue);
XContentBuilder out = jsonBuilder().startObject();
addValueToTheIndexField(out, indexFieldForRiverName, riverName);
addValueToTheIndexField(out, indexFieldForProjectKey, jiraProjectKey);
addValueToTheIndexField(out, indexFieldForIssueKey, issueKey);
addValueToTheIndexField(out, indexFieldForJiraURL, prepareJIRAGUIUrl(issueKey, null));
for (String indexFieldName : fieldsConfig.keySet()) {
Map<String, String> fieldConfig = fieldsConfig.get(indexFieldName);
addValueToTheIndex(out, indexFieldName, fieldConfig.get(CONFIG_FIELDS_JIRAFIELD), issue,
fieldConfig.get(CONFIG_FIELDS_VALUEFILTER));
}
if (commentIndexingMode == IssueCommentIndexingMode.EMBEDDED) {
List<Map<String, Object>> comments = extractIssueComments(issue);
if (comments != null && !comments.isEmpty()) {
out.startArray(indexFieldForComments);
for (Map<String, Object> comment : comments) {
out.startObject();
addCommonFieldsToCommentIndexedDocument(out, issueKey, comment);
out.endObject();
}
out.endArray();
}
}
if (changelogIndexingMode == IssueCommentIndexingMode.EMBEDDED) {
List<Map<String, Object>> changelogs = extractIssueChangelogs(issue);
if (changelogs != null && !changelogs.isEmpty()) {
out.startArray(indexFieldForChangelogs);
for (Map<String, Object> changelog : changelogs) {
out.startObject();
addCommonFieldsToChangelogIndexedDocument(out, issueKey, changelog);
out.endObject();
}
out.endArray();
}
}
return out.endObject();
}