use of org.graylog2.plugin.Message.FIELD_GL2_MESSAGE_ID in project graylog2-server by Graylog2.
the class V20200730000000_AddGl2MessageIdFieldAliasForEventsES7 method addGl2MessageIdFieldAlias.
@Override
public void addGl2MessageIdFieldAlias(Set<String> indexPrefixes) {
final String[] prefixesWithWildcard = indexPrefixes.stream().map(p -> p + "*").toArray(String[]::new);
final PutMappingRequest putMappingRequest = new PutMappingRequest(prefixesWithWildcard).indicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED).source(ImmutableMap.of("properties", ImmutableMap.of(FIELD_GL2_MESSAGE_ID, aliasMapping())));
try {
final AcknowledgedResponse acknowledgedResponse = client.execute((c, requestOptions) -> c.indices().putMapping(putMappingRequest, requestOptions));
if (!acknowledgedResponse.isAcknowledged()) {
throw new ElasticsearchException(errorMsgFor(prefixesWithWildcard) + " Elasticsearch failed to acknowledge.");
}
} catch (ElasticsearchException e) {
throw new ElasticsearchException(errorMsgFor(prefixesWithWildcard), e);
}
}
Aggregations