use of org.sonar.server.es.newindex.TypeMapping in project sonarqube by SonarSource.
the class IndexDefinitionHashTest method computeAndVerifyAllDifferentHashesOnMapping.
@SafeVarargs
private final void computeAndVerifyAllDifferentHashesOnMapping(IndexMainType mainType, Consumer<TypeMapping>... fieldTypes) {
List<TestNewIndex> mainIndices = Arrays.stream(fieldTypes).map(consumer -> {
TestNewIndex mainTypeMapping = new TestNewIndex(mainType, settingsConfiguration);
consumer.accept(mainTypeMapping.getMainTypeMapping());
return mainTypeMapping;
}).collect(toList());
List<TestNewIndex> relationIndices = Arrays.stream(fieldTypes).map(consumer -> {
TestNewIndex relationTypeMapping = new TestNewIndex(mainType, settingsConfiguration);
consumer.accept(relationTypeMapping.createRelationMapping("donut"));
return relationTypeMapping;
}).collect(toList());
Set<String> mainHashes = mainIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet());
Set<String> relationHashes = relationIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet());
assertThat(mainHashes).isEqualTo(mainIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet())).doesNotContainAnyElementsOf(relationHashes).hasSize(fieldTypes.length);
assertThat(relationHashes).isEqualTo(relationIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet())).doesNotContainAnyElementsOf(mainHashes).hasSize(fieldTypes.length);
}
use of org.sonar.server.es.newindex.TypeMapping in project sonarqube by SonarSource.
the class ComponentIndexDefinition method define.
@Override
public void define(IndexDefinitionContext context) {
NewAuthorizedIndex index = context.createWithAuthorization(DESCRIPTOR, newBuilder(config).setRefreshInterval(MANUAL_REFRESH_INTERVAL).setDefaultNbOfShards(DEFAULT_NUMBER_OF_SHARDS).build()).setEnableSource(enableSource);
TypeMapping mapping = index.createTypeMapping(TYPE_COMPONENT);
mapping.keywordFieldBuilder(FIELD_UUID).disableNorms().build();
mapping.keywordFieldBuilder(FIELD_PROJECT_UUID).disableNorms().build();
mapping.keywordFieldBuilder(FIELD_KEY).addSubFields(SORTABLE_ANALYZER).build();
mapping.textFieldBuilder(FIELD_NAME).withFieldData().store().termVectorWithPositionOffsets().addSubFields(NAME_ANALYZERS).build();
mapping.keywordFieldBuilder(FIELD_QUALIFIER).build();
}
use of org.sonar.server.es.newindex.TypeMapping in project sonarqube by SonarSource.
the class IndexDefinitionHashTest method computeAndVerifyAllSameHashesOnMapping.
@SafeVarargs
private final void computeAndVerifyAllSameHashesOnMapping(IndexMainType mainType, Consumer<TypeMapping>... fieldTypes) {
List<Consumer<TypeMapping>> fieldTypes1 = Arrays.asList(fieldTypes);
List<TestNewIndex> mainIndices = fieldTypes1.stream().map(consumer -> {
TestNewIndex mainTypeMapping = new TestNewIndex(mainType, settingsConfiguration);
consumer.accept(mainTypeMapping.getMainTypeMapping());
return mainTypeMapping;
}).collect(toList());
List<TestNewIndex> relationIndices = fieldTypes1.stream().map(consumer -> {
TestNewIndex relationTypeMapping = new TestNewIndex(mainType, settingsConfiguration);
consumer.accept(relationTypeMapping.createRelationMapping("donut"));
return relationTypeMapping;
}).collect(toList());
Set<String> mainHashes = mainIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet());
Set<String> relationHashes = relationIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet());
assertThat(mainHashes).isEqualTo(mainIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet())).doesNotContainAnyElementsOf(relationHashes).hasSize(1);
assertThat(relationHashes).isEqualTo(relationIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet())).doesNotContainAnyElementsOf(mainHashes).hasSize(1);
}
Aggregations