use of org.sonar.server.es.NewIndex in project sonarqube by SonarSource.
the class ComponentIndexDefinition method define.
@Override
public void define(IndexDefinitionContext context) {
NewIndex index = context.create(INDEX_TYPE_COMPONENT.getIndex());
index.refreshHandledByIndexer();
index.configureShards(settings, DEFAULT_NUMBER_OF_SHARDS);
NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_COMPONENT.getType()).requireProjectAuthorization();
mapping.stringFieldBuilder(FIELD_PROJECT_UUID).build();
mapping.stringFieldBuilder(FIELD_KEY).addSubFields(SORTABLE_ANALYZER).build();
mapping.stringFieldBuilder(FIELD_NAME).addSubFields(SORTABLE_ANALYZER, SEARCH_GRAMS_ANALYZER).build();
mapping.stringFieldBuilder(FIELD_QUALIFIER).build();
mapping.setEnableSource(false);
}
use of org.sonar.server.es.NewIndex in project sonarqube by SonarSource.
the class RuleIndexDefinitionTest method enable_replica_if_clustering_is_enabled.
@Test
public void enable_replica_if_clustering_is_enabled() {
settings.setProperty(ProcessProperties.CLUSTER_ENABLED, true);
IndexDefinition.IndexDefinitionContext context = new IndexDefinition.IndexDefinitionContext();
underTest.define(context);
NewIndex ruleIndex = context.getIndices().get("rules");
assertThat(ruleIndex.getSettings().get("index.number_of_replicas")).isEqualTo("1");
}
use of org.sonar.server.es.NewIndex in project sonarqube by SonarSource.
the class RuleIndexDefinitionTest method test_definition_of_index.
@Test
public void test_definition_of_index() {
IndexDefinition.IndexDefinitionContext context = new IndexDefinition.IndexDefinitionContext();
underTest.define(context);
assertThat(context.getIndices()).hasSize(1);
NewIndex ruleIndex = context.getIndices().get("rules");
assertThat(ruleIndex).isNotNull();
assertThat(ruleIndex.getTypes().keySet()).containsOnly("rule", "activeRule");
// no cluster by default
assertThat(ruleIndex.getSettings().get("index.number_of_shards")).isEqualTo("1");
assertThat(ruleIndex.getSettings().get("index.number_of_replicas")).isEqualTo("0");
}
Aggregations