use of org.sonar.server.es.metadata.MetadataIndexDefinition.TYPE_METADATA in project sonarqube by SonarSource.
the class IndexCreator method start.
@Override
public void start() {
// create the "metadata" index first
IndexType.IndexMainType metadataMainType = TYPE_METADATA;
if (!client.indexExists(new GetIndexRequest(metadataMainType.getIndex().getName()))) {
IndexDefinition.IndexDefinitionContext context = new IndexDefinition.IndexDefinitionContext();
metadataIndexDefinition.define(context);
NewIndex index = context.getIndices().values().iterator().next();
createIndex(index.build(), false);
} else {
ensureWritable(metadataMainType);
}
checkDbCompatibility(definitions.getIndices().values());
// create indices that do not exist or that have a new definition (different mapping, cluster enabled, ...)
definitions.getIndices().values().stream().filter(i -> !i.getMainType().equals(metadataMainType)).forEach(index -> {
boolean exists = client.indexExists(new GetIndexRequest(index.getMainType().getIndex().getName()));
if (!exists) {
createIndex(index, true);
} else if (hasDefinitionChange(index)) {
updateIndex(index);
} else {
ensureWritable(index.getMainType());
}
});
}
Aggregations