Search in sources :

Example 1 with NewIndex

use of org.sonar.server.es.NewIndex in project sonarqube by SonarSource.

the class UserIndexDefinitionTest method define.

@Test
public void define() {
    UserIndexDefinition def = new UserIndexDefinition(new MapSettings());
    def.define(underTest);
    assertThat(underTest.getIndices()).hasSize(1);
    NewIndex index = underTest.getIndices().get("users");
    assertThat(index).isNotNull();
    assertThat(index.getTypes().keySet()).containsOnly("user");
    // no cluster by default
    assertThat(index.getSettings().get("index.number_of_shards")).isEqualTo("1");
    assertThat(index.getSettings().get("index.number_of_replicas")).isEqualTo("0");
}
Also used : MapSettings(org.sonar.api.config.MapSettings) NewIndex(org.sonar.server.es.NewIndex) Test(org.junit.Test)

Example 2 with NewIndex

use of org.sonar.server.es.NewIndex in project sonarqube by SonarSource.

the class ViewIndexDefinitionTest method define.

@Test
public void define() {
    ViewIndexDefinition def = new ViewIndexDefinition(new MapSettings());
    def.define(underTest);
    assertThat(underTest.getIndices()).hasSize(1);
    NewIndex index = underTest.getIndices().get("views");
    assertThat(index).isNotNull();
    assertThat(index.getTypes().keySet()).containsOnly("view");
    assertThat(index.getSettings().get("index.number_of_shards")).isEqualTo("5");
    assertThat(index.getSettings().get("index.number_of_replicas")).isEqualTo("0");
}
Also used : MapSettings(org.sonar.api.config.MapSettings) NewIndex(org.sonar.server.es.NewIndex) Test(org.junit.Test)

Example 3 with NewIndex

use of org.sonar.server.es.NewIndex in project sonarqube by SonarSource.

the class IssueIndexDefinition method define.

@Override
public void define(IndexDefinitionContext context) {
    NewIndex index = context.create(INDEX_TYPE_ISSUE.getIndex());
    index.refreshHandledByIndexer();
    index.configureShards(settings, 5);
    NewIndex.NewIndexType type = index.createType(INDEX_TYPE_ISSUE.getType());
    type.requireProjectAuthorization();
    type.stringFieldBuilder(FIELD_ISSUE_ASSIGNEE).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
    type.stringFieldBuilder(FIELD_ISSUE_ATTRIBUTES).disableNorms().disableSearch().build();
    type.stringFieldBuilder(FIELD_ISSUE_AUTHOR_LOGIN).disableNorms().build();
    type.stringFieldBuilder(FIELD_ISSUE_COMPONENT_UUID).disableNorms().build();
    type.createLongField(FIELD_ISSUE_EFFORT);
    type.createDoubleField(FIELD_ISSUE_GAP);
    type.stringFieldBuilder(FIELD_ISSUE_FILE_PATH).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
    type.createDateTimeField(FIELD_ISSUE_FUNC_CREATED_AT);
    type.createDateTimeField(FIELD_ISSUE_FUNC_UPDATED_AT);
    type.createDateTimeField(FIELD_ISSUE_FUNC_CLOSED_AT);
    type.stringFieldBuilder(FIELD_ISSUE_KEY).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
    type.stringFieldBuilder(FIELD_ISSUE_LANGUAGE).disableNorms().build();
    type.createIntegerField(FIELD_ISSUE_LINE);
    type.stringFieldBuilder(FIELD_ISSUE_MESSAGE).disableNorms().build();
    type.stringFieldBuilder(FIELD_ISSUE_MODULE_UUID).disableNorms().build();
    type.createUuidPathField(FIELD_ISSUE_MODULE_PATH);
    type.stringFieldBuilder(FIELD_ISSUE_PROJECT_UUID).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
    type.stringFieldBuilder(FIELD_ISSUE_DIRECTORY_PATH).disableNorms().build();
    type.stringFieldBuilder(FIELD_ISSUE_RESOLUTION).disableNorms().build();
    type.stringFieldBuilder(FIELD_ISSUE_RULE_KEY).disableNorms().build();
    type.stringFieldBuilder(FIELD_ISSUE_SEVERITY).disableNorms().build();
    type.createByteField(FIELD_ISSUE_SEVERITY_VALUE);
    type.stringFieldBuilder(FIELD_ISSUE_STATUS).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
    type.stringFieldBuilder(FIELD_ISSUE_TAGS).disableNorms().build();
    type.createDateTimeField(FIELD_ISSUE_TECHNICAL_UPDATED_AT);
    type.stringFieldBuilder(FIELD_ISSUE_TYPE).disableNorms().build();
}
Also used : NewIndex(org.sonar.server.es.NewIndex)

Example 4 with NewIndex

use of org.sonar.server.es.NewIndex in project sonarqube by SonarSource.

the class ProjectMeasuresIndexDefinition method define.

@Override
public void define(IndexDefinitionContext context) {
    NewIndex index = context.create(INDEX_TYPE_PROJECT_MEASURES.getIndex());
    index.refreshHandledByIndexer();
    index.configureShards(settings, 5);
    NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_PROJECT_MEASURES.getType()).requireProjectAuthorization();
    mapping.stringFieldBuilder(FIELD_ORGANIZATION_UUID).build();
    mapping.stringFieldBuilder(FIELD_KEY).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
    mapping.stringFieldBuilder(FIELD_NAME).addSubFields(SORTABLE_ANALYZER, SEARCH_GRAMS_ANALYZER).build();
    mapping.stringFieldBuilder(FIELD_QUALITY_GATE_STATUS).build();
    mapping.stringFieldBuilder(FIELD_TAGS).build();
    mapping.stringFieldBuilder(FIELD_LANGUAGES).build();
    mapping.nestedFieldBuilder(FIELD_MEASURES).addStringField(FIELD_MEASURES_KEY).addDoubleField(FIELD_MEASURES_VALUE).build();
    mapping.createDateTimeField(FIELD_ANALYSED_AT);
    mapping.setEnableSource(false);
}
Also used : NewIndex(org.sonar.server.es.NewIndex)

Example 5 with NewIndex

use of org.sonar.server.es.NewIndex in project sonarqube by SonarSource.

the class RuleIndexDefinition method define.

@Override
public void define(IndexDefinitionContext context) {
    NewIndex index = context.create(INDEX_TYPE_RULE.getIndex());
    index.refreshHandledByIndexer();
    index.configureShards(settings, 1);
    // Active rule type
    NewIndex.NewIndexType activeRuleMapping = index.createType(RuleIndexDefinition.INDEX_TYPE_ACTIVE_RULE.getType());
    activeRuleMapping.setEnableSource(false);
    activeRuleMapping.setAttribute("_parent", ImmutableMap.of("type", RuleIndexDefinition.INDEX_TYPE_RULE.getType()));
    activeRuleMapping.stringFieldBuilder(RuleIndexDefinition.FIELD_ACTIVE_RULE_KEY).addSubFields(SORTABLE_ANALYZER).build();
    activeRuleMapping.stringFieldBuilder(RuleIndexDefinition.FIELD_ACTIVE_RULE_RULE_KEY).addSubFields(SORTABLE_ANALYZER).build();
    activeRuleMapping.stringFieldBuilder(RuleIndexDefinition.FIELD_ACTIVE_RULE_REPOSITORY).build();
    activeRuleMapping.stringFieldBuilder(RuleIndexDefinition.FIELD_ACTIVE_RULE_PROFILE_KEY).disableNorms().build();
    activeRuleMapping.stringFieldBuilder(RuleIndexDefinition.FIELD_ACTIVE_RULE_INHERITANCE).disableNorms().build();
    activeRuleMapping.stringFieldBuilder(RuleIndexDefinition.FIELD_ACTIVE_RULE_SEVERITY).disableNorms().build();
    activeRuleMapping.createLongField(RuleIndexDefinition.FIELD_ACTIVE_RULE_CREATED_AT);
    activeRuleMapping.createLongField(RuleIndexDefinition.FIELD_ACTIVE_RULE_UPDATED_AT);
    // Rule type
    NewIndex.NewIndexType ruleMapping = index.createType(RuleIndexDefinition.INDEX_TYPE_RULE.getType());
    ruleMapping.setEnableSource(false);
    ruleMapping.stringFieldBuilder(FIELD_RULE_KEY).addSubFields(SORTABLE_ANALYZER).build();
    ruleMapping.stringFieldBuilder(FIELD_RULE_RULE_KEY).addSubFields(SORTABLE_ANALYZER).build();
    ruleMapping.stringFieldBuilder(FIELD_RULE_REPOSITORY).build();
    ruleMapping.stringFieldBuilder(FIELD_RULE_INTERNAL_KEY).disableNorms().disableSearch().build();
    ruleMapping.stringFieldBuilder(FIELD_RULE_NAME).addSubFields(SORTABLE_ANALYZER, SEARCH_WORDS_ANALYZER).build();
    ruleMapping.setProperty(FIELD_RULE_HTML_DESCRIPTION, ImmutableSortedMap.of(DefaultIndexSettings.TYPE, DefaultIndexSettings.STRING, DefaultIndexSettings.INDEX, DefaultIndexSettings.ANALYZED, DefaultIndexSettings.ANALYZER, ENGLISH_HTML_ANALYZER.getName(), DefaultIndexSettings.SEARCH_ANALYZER, ENGLISH_HTML_ANALYZER.getName()));
    ruleMapping.stringFieldBuilder(FIELD_RULE_SEVERITY).disableNorms().build();
    ruleMapping.stringFieldBuilder(FIELD_RULE_STATUS).disableNorms().build();
    ruleMapping.stringFieldBuilder(FIELD_RULE_LANGUAGE).disableNorms().build();
    ruleMapping.createBooleanField(FIELD_RULE_IS_TEMPLATE);
    ruleMapping.stringFieldBuilder(FIELD_RULE_TEMPLATE_KEY).disableNorms().build();
    ruleMapping.stringFieldBuilder(FIELD_RULE_ALL_TAGS).addSubFields(SEARCH_WORDS_ANALYZER).build();
    ruleMapping.stringFieldBuilder(FIELD_RULE_TYPE).disableNorms().build();
    ruleMapping.createLongField(FIELD_RULE_CREATED_AT);
    ruleMapping.createLongField(FIELD_RULE_UPDATED_AT);
}
Also used : NewIndex(org.sonar.server.es.NewIndex)

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