import java.util.HashMap;
import org.sonar.server.es.BaseDoc;
+import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_KEY;
+import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_NAME;
+import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_PROJECT_UUID;
+import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_QUALIFIER;
+import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_UUID;
+
public class ComponentDoc extends BaseDoc {
public ComponentDoc() {
- super(new HashMap<>(5));
+ super(new HashMap<>(6));
}
@Override
public String getId() {
- return getField("_id");
+ return getField(FIELD_UUID);
}
@Override
}
public ComponentDoc setId(String s) {
- setField("_id", s);
+ setField(FIELD_UUID, s);
return this;
}
public String getProjectUuid() {
- return getField(ComponentIndexDefinition.FIELD_PROJECT_UUID);
+ return getField(FIELD_PROJECT_UUID);
}
public ComponentDoc setProjectUuid(String s) {
- setField(ComponentIndexDefinition.FIELD_PROJECT_UUID, s);
+ setField(FIELD_PROJECT_UUID, s);
return this;
}
public String getKey() {
- return getField(ComponentIndexDefinition.FIELD_KEY);
+ return getField(FIELD_KEY);
}
public ComponentDoc setKey(String s) {
- setField(ComponentIndexDefinition.FIELD_KEY, s);
+ setField(FIELD_KEY, s);
return this;
}
public String getName() {
- return getField(ComponentIndexDefinition.FIELD_NAME);
+ return getField(FIELD_NAME);
}
public ComponentDoc setName(String s) {
- setField(ComponentIndexDefinition.FIELD_NAME, s);
+ setField(FIELD_NAME, s);
return this;
}
public String getQualifier() {
- return getField(ComponentIndexDefinition.FIELD_QUALIFIER);
+ return getField(FIELD_QUALIFIER);
}
public ComponentDoc setQualifier(String s) {
- setField(ComponentIndexDefinition.FIELD_QUALIFIER, s);
+ setField(FIELD_QUALIFIER, s);
return this;
}
}
public class ComponentIndexDefinition implements IndexDefinition {
public static final IndexType INDEX_TYPE_COMPONENT = new IndexType("components", "component");
+ public static final String FIELD_UUID = "uuid";
public static final String FIELD_PROJECT_UUID = "project_uuid";
public static final String FIELD_KEY = "key";
public static final String FIELD_NAME = "name";
NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_COMPONENT.getType())
.requireProjectAuthorization();
- mapping.keywordFieldBuilder(FIELD_PROJECT_UUID).build();
+ mapping.keywordFieldBuilder(FIELD_UUID).disableNorms().build();
+ mapping.keywordFieldBuilder(FIELD_PROJECT_UUID).disableNorms().build();
mapping.keywordFieldBuilder(FIELD_KEY).addSubFields(SORTABLE_ANALYZER).build();
mapping.keywordFieldBuilder(FIELD_NAME)
.termVectorWithPositionOffsets()
import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_ORGANIZATION_UUID;
import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_QUALITY_GATE_STATUS;
import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_TAGS;
+import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_UUID;
public class ProjectMeasuresDoc extends BaseDoc {
public static final Map<String, Integer> QUALITY_GATE_STATUS = ImmutableMap.of(OK.name(), 1, WARN.name(), 2, ERROR.name(), 3);
public ProjectMeasuresDoc() {
- super(new HashMap<>(7));
+ super(new HashMap<>(8));
}
@Override
public String getId() {
- return getField("_id");
+ return getField(FIELD_UUID);
}
@Override
}
public ProjectMeasuresDoc setId(String s) {
- setField("_id", s);
+ setField(FIELD_UUID, s);
return this;
}
public class ProjectMeasuresIndexDefinition implements IndexDefinition {
public static final IndexType INDEX_TYPE_PROJECT_MEASURES = new IndexType("projectmeasures", "projectmeasure");
+ public static final String FIELD_UUID = "uuid";
public static final String FIELD_ORGANIZATION_UUID = "organizationUuid";
public static final String FIELD_KEY = "key";
public static final String FIELD_NAME = "name";
NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_PROJECT_MEASURES.getType())
.requireProjectAuthorization();
- mapping.keywordFieldBuilder(FIELD_ORGANIZATION_UUID).build();
+ mapping.keywordFieldBuilder(FIELD_UUID).disableNorms().build();
+ mapping.keywordFieldBuilder(FIELD_ORGANIZATION_UUID).disableNorms().build();
mapping.keywordFieldBuilder(FIELD_KEY).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
mapping.keywordFieldBuilder(FIELD_NAME).addSubFields(SORTABLE_ANALYZER, SEARCH_GRAMS_ANALYZER).build();
mapping.keywordFieldBuilder(FIELD_QUALITY_GATE_STATUS).build();
import org.sonar.server.qualityprofile.ActiveRule;
import static org.apache.commons.lang.StringUtils.containsIgnoreCase;
+import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_ID;
import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_INHERITANCE;
import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_PROFILE_UUID;
import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_REPOSITORY;
public class ActiveRuleDoc extends BaseDoc {
- public ActiveRuleDoc(String id) {
- super(Maps.newHashMapWithExpectedSize(9));
- setField("_id", id);
+ public ActiveRuleDoc(long id) {
+ super(Maps.newHashMapWithExpectedSize(10));
+ setField(FIELD_ACTIVE_RULE_ID, String.valueOf(id));
}
public ActiveRuleDoc(Map<String,Object> source) {
@Override
public String getId() {
- return getField("_id");
+ return getField(FIELD_ACTIVE_RULE_ID);
}
@Override
}
private static IndexRequest newIndexRequest(IndexedActiveRuleDto dto) {
- ActiveRuleDoc doc = new ActiveRuleDoc(String.valueOf(dto.getId()));
+ ActiveRuleDoc doc = new ActiveRuleDoc(dto.getId());
doc.setRuleProfileUuid(dto.getRuleProfileUuid());
doc.setSeverity(SeverityUtil.getSeverityFromOrdinal(dto.getSeverity()));
doc.setRuleKey(RuleKey.of(dto.getRepository(), dto.getKey()));
// Active rule fields
public static final IndexType INDEX_TYPE_ACTIVE_RULE = new IndexType(INDEX, "activeRule");
+ public static final String FIELD_ACTIVE_RULE_ID = "id";
public static final String FIELD_ACTIVE_RULE_REPOSITORY = "repo";
public static final String FIELD_ACTIVE_RULE_INHERITANCE = "inheritance";
public static final String FIELD_ACTIVE_RULE_PROFILE_UUID = "ruleProfile";
activeRuleMapping.setEnableSource(enableSource);
activeRuleMapping.setAttribute("_parent", ImmutableMap.of("type", INDEX_TYPE_RULE.getType()));
+ activeRuleMapping.keywordFieldBuilder(FIELD_ACTIVE_RULE_ID).disableNorms().build();
activeRuleMapping.keywordFieldBuilder(FIELD_ACTIVE_RULE_RULE_KEY).addSubFields(SORTABLE_ANALYZER).build();
activeRuleMapping.keywordFieldBuilder(FIELD_ACTIVE_RULE_REPOSITORY).build();
activeRuleMapping.keywordFieldBuilder(FIELD_ACTIVE_RULE_PROFILE_UUID).disableNorms().build();