Search in sources :

Example 1 with TypeMapping

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

the class ProjectMeasuresIndexDefinition method define.

@Override
public void define(IndexDefinitionContext context) {
    NewAuthorizedIndex index = context.createWithAuthorization(DESCRIPTOR, newBuilder(config).setRefreshInterval(MANUAL_REFRESH_INTERVAL).setDefaultNbOfShards(5).build()).setEnableSource(enableSource);
    TypeMapping mapping = index.createTypeMapping(TYPE_PROJECT_MEASURES);
    mapping.keywordFieldBuilder(FIELD_UUID).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_KEY).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
    mapping.keywordFieldBuilder(FIELD_QUALIFIER).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_NAME).addSubFields(SORTABLE_ANALYZER, SEARCH_GRAMS_ANALYZER).build();
    mapping.keywordFieldBuilder(FIELD_QUALITY_GATE_STATUS).build();
    mapping.keywordFieldBuilder(FIELD_TAGS).build();
    mapping.keywordFieldBuilder(FIELD_LANGUAGES).build();
    mapping.nestedFieldBuilder(FIELD_MEASURES).addKeywordField(SUB_FIELD_MEASURES_KEY).addDoubleField(SUB_FIELD_MEASURES_VALUE).build();
    mapping.nestedFieldBuilder(FIELD_NCLOC_DISTRIBUTION).addKeywordField(SUB_FIELD_DISTRIB_LANGUAGE).addIntegerField(SUB_FIELD_DISTRIB_NCLOC).build();
    mapping.createDateTimeField(FIELD_ANALYSED_AT);
}
Also used : NewAuthorizedIndex(org.sonar.server.es.newindex.NewAuthorizedIndex) TypeMapping(org.sonar.server.es.newindex.TypeMapping)

Example 2 with TypeMapping

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

the class RuleIndexDefinition method define.

@Override
public void define(IndexDefinitionContext context) {
    NewRegularIndex index = context.create(DESCRIPTOR, newBuilder(config).setRefreshInterval(MANUAL_REFRESH_INTERVAL).setDefaultNbOfShards(2).build()).setEnableSource(enableSource);
    // Rule type
    TypeMapping ruleMapping = index.createTypeMapping(TYPE_RULE);
    ruleMapping.keywordFieldBuilder(FIELD_RULE_UUID).disableNorms().build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_KEY).addSubFields(SORTABLE_ANALYZER).build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_RULE_KEY).addSubFields(SORTABLE_ANALYZER).build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_REPOSITORY).build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_INTERNAL_KEY).disableNorms().disableSearch().build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_NAME).addSubFields(SORTABLE_ANALYZER, SEARCH_GRAMS_ANALYZER).build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_HTML_DESCRIPTION).disableSearch().disableNorms().disableSortingAndAggregating().addSubFields(ENGLISH_HTML_ANALYZER).build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_SEVERITY).disableNorms().build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_STATUS).disableNorms().build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_LANGUAGE).disableNorms().build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_TAGS).build();
    ruleMapping.createBooleanField(FIELD_RULE_IS_TEMPLATE);
    ruleMapping.createBooleanField(FIELD_RULE_IS_EXTERNAL);
    ruleMapping.keywordFieldBuilder(FIELD_RULE_TEMPLATE_KEY).disableNorms().build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_TYPE).disableNorms().build();
    ruleMapping.createLongField(FIELD_RULE_CREATED_AT);
    ruleMapping.createLongField(FIELD_RULE_UPDATED_AT);
    ruleMapping.keywordFieldBuilder(FIELD_RULE_CWE).disableNorms().build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_OWASP_TOP_10).disableNorms().build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_SANS_TOP_25).disableNorms().build();
    ruleMapping.keywordFieldBuilder(FIELD_RULE_SONARSOURCE_SECURITY).disableNorms().build();
    // Active rule
    index.createTypeMapping(TYPE_ACTIVE_RULE).keywordFieldBuilder(FIELD_ACTIVE_RULE_UUID).disableNorms().build().keywordFieldBuilder(FIELD_ACTIVE_RULE_PROFILE_UUID).disableNorms().build().keywordFieldBuilder(FIELD_ACTIVE_RULE_INHERITANCE).disableNorms().build().keywordFieldBuilder(FIELD_ACTIVE_RULE_SEVERITY).disableNorms().build();
}
Also used : NewRegularIndex(org.sonar.server.es.newindex.NewRegularIndex) TypeMapping(org.sonar.server.es.newindex.TypeMapping)

Example 3 with TypeMapping

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

the class UserIndexDefinition method define.

@Override
public void define(IndexDefinitionContext context) {
    NewRegularIndex index = context.create(DESCRIPTOR, newBuilder(config).setDefaultNbOfShards(1).build()).setEnableSource(true);
    TypeMapping mapping = index.createTypeMapping(TYPE_USER);
    mapping.keywordFieldBuilder(FIELD_UUID).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_LOGIN).addSubFields(USER_SEARCH_GRAMS_ANALYZER).build();
    mapping.keywordFieldBuilder(FIELD_NAME).addSubFields(USER_SEARCH_GRAMS_ANALYZER).build();
    mapping.keywordFieldBuilder(FIELD_EMAIL).addSubFields(USER_SEARCH_GRAMS_ANALYZER, SORTABLE_ANALYZER).build();
    mapping.createBooleanField(FIELD_ACTIVE);
    mapping.keywordFieldBuilder(FIELD_SCM_ACCOUNTS).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
}
Also used : NewRegularIndex(org.sonar.server.es.newindex.NewRegularIndex) TypeMapping(org.sonar.server.es.newindex.TypeMapping)

Example 4 with TypeMapping

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

the class ViewIndexDefinition method define.

@Override
public void define(IndexDefinitionContext context) {
    NewRegularIndex index = context.create(DESCRIPTOR, newBuilder(config).setDefaultNbOfShards(5).build()).setEnableSource(true);
    // type "view"
    TypeMapping mapping = index.createTypeMapping(TYPE_VIEW);
    mapping.keywordFieldBuilder(FIELD_UUID).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_PROJECTS).disableNorms().build();
}
Also used : NewRegularIndex(org.sonar.server.es.newindex.NewRegularIndex) TypeMapping(org.sonar.server.es.newindex.TypeMapping)

Example 5 with TypeMapping

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

the class IssueIndexDefinition method define.

@Override
public void define(IndexDefinitionContext context) {
    NewAuthorizedIndex index = context.createWithAuthorization(DESCRIPTOR, newBuilder(config).setRefreshInterval(MANUAL_REFRESH_INTERVAL).setDefaultNbOfShards(5).build()).setEnableSource(enableSource);
    TypeMapping mapping = index.createTypeMapping(TYPE_ISSUE);
    mapping.keywordFieldBuilder(FIELD_ISSUE_ASSIGNEE_UUID).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_AUTHOR_LOGIN).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_COMPONENT_UUID).disableNorms().build();
    mapping.createLongField(FIELD_ISSUE_EFFORT);
    mapping.keywordFieldBuilder(FIELD_ISSUE_FILE_PATH).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
    mapping.createDateTimeField(FIELD_ISSUE_FUNC_CREATED_AT);
    mapping.createDateTimeField(FIELD_ISSUE_FUNC_UPDATED_AT);
    mapping.createDateTimeField(FIELD_ISSUE_FUNC_CLOSED_AT);
    mapping.keywordFieldBuilder(FIELD_ISSUE_KEY).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_SCOPE).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_LANGUAGE).disableNorms().build();
    mapping.createIntegerField(FIELD_ISSUE_LINE);
    mapping.keywordFieldBuilder(FIELD_ISSUE_MODULE_UUID).disableNorms().build();
    mapping.createUuidPathField(FIELD_ISSUE_MODULE_PATH);
    mapping.keywordFieldBuilder(FIELD_ISSUE_PROJECT_UUID).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_BRANCH_UUID).disableNorms().build();
    mapping.createBooleanField(FIELD_ISSUE_IS_MAIN_BRANCH);
    mapping.keywordFieldBuilder(FIELD_ISSUE_DIRECTORY_PATH).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_RESOLUTION).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_RULE_UUID).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_SEVERITY).disableNorms().build();
    mapping.createByteField(FIELD_ISSUE_SEVERITY_VALUE);
    mapping.keywordFieldBuilder(FIELD_ISSUE_STATUS).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_TAGS).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_TYPE).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_OWASP_TOP_10).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_SANS_TOP_25).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_CWE).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_SQ_SECURITY_CATEGORY).disableNorms().build();
    mapping.keywordFieldBuilder(FIELD_ISSUE_VULNERABILITY_PROBABILITY).disableNorms().build();
    mapping.createBooleanField(FIELD_ISSUE_NEW_CODE_REFERENCE);
}
Also used : NewAuthorizedIndex(org.sonar.server.es.newindex.NewAuthorizedIndex) TypeMapping(org.sonar.server.es.newindex.TypeMapping)

Aggregations

TypeMapping (org.sonar.server.es.newindex.TypeMapping)8 NewAuthorizedIndex (org.sonar.server.es.newindex.NewAuthorizedIndex)3 NewRegularIndex (org.sonar.server.es.newindex.NewRegularIndex)3 Arrays (java.util.Arrays)2 List (java.util.List)2 Set (java.util.Set)2 Consumer (java.util.function.Consumer)2 Collectors.toList (java.util.stream.Collectors.toList)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Test (org.junit.Test)2 Configuration (org.sonar.api.config.Configuration)2 MapSettings (org.sonar.api.config.internal.MapSettings)2 CLUSTER_ENABLED (org.sonar.process.ProcessProperties.Property.CLUSTER_ENABLED)2 IndexMainType (org.sonar.server.es.IndexType.IndexMainType)2 SettingsConfiguration (org.sonar.server.es.newindex.SettingsConfiguration)2 TestNewIndex (org.sonar.server.es.newindex.TestNewIndex)2