Search in sources :

Example 11 with NewIndex

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);
}
Also used : NewIndex(org.sonar.server.es.NewIndex)

Example 12 with NewIndex

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");
}
Also used : IndexDefinition(org.sonar.server.es.IndexDefinition) NewIndex(org.sonar.server.es.NewIndex) Test(org.junit.Test)

Example 13 with NewIndex

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");
}
Also used : IndexDefinition(org.sonar.server.es.IndexDefinition) NewIndex(org.sonar.server.es.NewIndex) Test(org.junit.Test)

Aggregations

NewIndex (org.sonar.server.es.NewIndex)13 Test (org.junit.Test)5 MapSettings (org.sonar.api.config.MapSettings)3 IndexDefinition (org.sonar.server.es.IndexDefinition)2