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();
}
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();
}
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();
}
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);
}
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");
}
Aggregations