in data-prepper-plugins/opensearch/src/main/java/com/amazon/dataprepper/plugins/sink/opensearch/index/IndexConfiguration.java [48:82]
private IndexConfiguration(final Builder builder) {
determineIndexType(builder);
this.indexTemplate = readIndexTemplate(builder.templateFile, indexType);
if (builder.numReplicas > 0) {
indexTemplate.putIfAbsent(SETTINGS, new HashMap<>());
((Map<String, Object>) indexTemplate.get(SETTINGS)).putIfAbsent(NUM_REPLICAS, builder.numReplicas);
}
if (builder.numShards > 0) {
indexTemplate.putIfAbsent(SETTINGS, new HashMap<>());
((Map<String, Object>) indexTemplate.get(SETTINGS)).putIfAbsent(NUM_SHARDS, builder.numShards);
}
String indexAlias = builder.indexAlias;
if (IndexConstants.TYPE_TO_DEFAULT_ALIAS.containsKey(indexType)) {
indexAlias = IndexConstants.TYPE_TO_DEFAULT_ALIAS.get(indexType);
} else {
if (indexAlias == null) {
throw new IllegalStateException("Missing required properties:indexAlias");
}
}
this.indexAlias = indexAlias;
this.bulkSize = builder.bulkSize;
String documentIdField = builder.documentIdField;
if (indexType.equals(IndexType.TRACE_ANALYTICS_RAW)) {
documentIdField = "spanId";
} else if (indexType.equals(IndexType.TRACE_ANALYTICS_SERVICE_MAP)) {
documentIdField = "hashId";
}
this.documentIdField = documentIdField;
this.ismPolicyFile = builder.ismPolicyFile;
}