Search in sources :

Example 6 with NewIndex

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

the class UserIndexDefinition method define.

@Override
public void define(IndexDefinitionContext context) {
    NewIndex index = context.create(INDEX_TYPE_USER.getIndex());
    index.configureShards(settings, 1);
    // type "user"
    NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_USER.getType());
    mapping.stringFieldBuilder(FIELD_LOGIN).addSubFields(USER_SEARCH_GRAMS_ANALYZER).build();
    mapping.stringFieldBuilder(FIELD_NAME).addSubFields(USER_SEARCH_GRAMS_ANALYZER).build();
    mapping.stringFieldBuilder(FIELD_EMAIL).addSubFields(USER_SEARCH_GRAMS_ANALYZER, SORTABLE_ANALYZER).build();
    mapping.createDateTimeField(FIELD_CREATED_AT);
    mapping.createDateTimeField(FIELD_UPDATED_AT);
    mapping.createBooleanField(FIELD_ACTIVE);
    mapping.stringFieldBuilder(FIELD_SCM_ACCOUNTS).disableNorms().build();
}
Also used : NewIndex(org.sonar.server.es.NewIndex)

Example 7 with NewIndex

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

the class ViewIndexDefinition method define.

@Override
public void define(IndexDefinitionContext context) {
    NewIndex index = context.create(INDEX_TYPE_VIEW.getIndex());
    index.configureShards(settings, 5);
    // type "view"
    NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_VIEW.getType());
    mapping.stringFieldBuilder(FIELD_UUID).disableNorms().build();
    mapping.stringFieldBuilder(FIELD_PROJECTS).disableNorms().build();
}
Also used : NewIndex(org.sonar.server.es.NewIndex)

Example 8 with NewIndex

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

the class FooIndexDefinition method define.

@Override
public void define(IndexDefinitionContext context) {
    NewIndex index = context.create(FOO_INDEX);
    index.refreshHandledByIndexer();
    NewIndex.NewIndexType type = index.createType(FOO_TYPE).requireProjectAuthorization();
    type.stringFieldBuilder(FIELD_NAME).build();
    type.stringFieldBuilder(FIELD_PROJECT_UUID).build();
}
Also used : NewIndex(org.sonar.server.es.NewIndex)

Example 9 with NewIndex

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

the class TestIndexDefinition method define.

@Override
public void define(IndexDefinitionContext context) {
    NewIndex index = context.create(INDEX_TYPE_TEST.getIndex());
    index.refreshHandledByIndexer();
    index.configureShards(settings, 5);
    NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_TEST.getType());
    mapping.setAttribute("_routing", ImmutableMap.of("required", true));
    mapping.stringFieldBuilder(FIELD_PROJECT_UUID).disableNorms().build();
    mapping.stringFieldBuilder(FIELD_FILE_UUID).disableNorms().build();
    mapping.stringFieldBuilder(FIELD_TEST_UUID).disableNorms().build();
    mapping.stringFieldBuilder(FIELD_NAME).disableNorms().disableSearch().build();
    mapping.stringFieldBuilder(FIELD_STATUS).disableNorms().disableSearch().build();
    mapping.createLongField(FIELD_DURATION_IN_MS);
    mapping.stringFieldBuilder(FIELD_MESSAGE).disableNorms().disableSearch().build();
    mapping.stringFieldBuilder(FIELD_STACKTRACE).disableNorms().disableSearch().build();
    mapping.setProperty(FIELD_COVERED_FILES, ImmutableMap.of("type", "nested", "properties", ImmutableMap.of(FIELD_COVERED_FILE_UUID, ImmutableMap.of("type", "string", "index", "not_analyzed"), FIELD_COVERED_FILE_LINES, ImmutableMap.of("type", "integer"))));
    mapping.createDateTimeField(FIELD_UPDATED_AT);
}
Also used : NewIndex(org.sonar.server.es.NewIndex)

Example 10 with NewIndex

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

the class IssueIndexDefinitionTest method define.

@Test
public void define() {
    IssueIndexDefinition def = new IssueIndexDefinition(new MapSettings());
    def.define(underTest);
    assertThat(underTest.getIndices()).hasSize(1);
    NewIndex issuesIndex = underTest.getIndices().get("issues");
    assertThat(issuesIndex).isNotNull();
    assertThat(issuesIndex.getTypes().keySet()).containsOnly("issue", "authorization");
    // no cluster by default
    assertThat(issuesIndex.getSettings().get("index.number_of_shards")).isEqualTo("5");
    assertThat(issuesIndex.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)

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