private static final Logger LOG = LoggerFactory.getLogger(SearchIndex.class);
private static final String HTTP_ENABLED = "http.enabled";
- private static final String INSTANCE_NAME = "sonarqube";
static final String DATA_DIR = "data/es";
private static final String DEFAULT_HEALTH_TIMEOUT = "30s";
package org.sonar.server.rule;
-import org.sonar.server.es.SearchIndex;
-import org.sonar.server.es.SearchQuery;
-
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import org.apache.ibatis.session.SqlSession;
import org.sonar.core.qualityprofile.db.ActiveRuleDto;
import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
import org.sonar.core.rule.*;
+import org.sonar.server.es.SearchIndex;
+import org.sonar.server.es.SearchQuery;
import java.io.IOException;
import java.util.Arrays;
}
public void start() {
- searchIndex.addMappingFromClasspath(INDEX_RULES, TYPE_RULE, "/com/sonar/search/rule_mapping.json");
- searchIndex.addMappingFromClasspath(INDEX_RULES, TYPE_ACTIVE_RULE, "/com/sonar/search/active_rule_mapping.json");
+ searchIndex.addMappingFromClasspath(INDEX_RULES, TYPE_RULE, "/org/sonar/server/es/config/mappings/rule_mapping.json");
+ searchIndex.addMappingFromClasspath(INDEX_RULES, TYPE_ACTIVE_RULE, "/org/sonar/server/es/config/mappings/active_rule_mapping.json");
}
public void bulkRegisterRules(Collection<RuleDto> rules, Multimap<Integer, RuleParamDto> paramsByRule, Multimap<Integer, RuleTagDto> tagsByRule) {
+++ /dev/null
-{
- "active_rule": {
- "_id": {
- "path": "id"
- },
- "_parent": {
- "type": "rule"
- },
- "properties": {
- "id": {
- "type": "integer",
- "index": "not_analyzed"
- },
- "severity": {
- "type": "string",
- "index": "not_analyzed"
- },
- "profileId": {
- "type": "integer",
- "index": "not_analyzed"
- },
- "parentId": {
- "type": "integer",
- "index": "not_analyzed"
- },
- "inheritance": {
- "type": "string",
- "index": "not_analyzed"
- },
- "note": {
- "properties": {
- "data": {
- "type": "string",
- "index": "no"
- },
- "userLogin": {
- "type": "string",
- "index": "no"
- },
- "createdAt": {
- "type": "date",
- "format": "date_optional_time"
- },
- "updatedAt": {
- "type": "date",
- "format": "date_optional_time"
- }
- }
- },
- "params": {
- "properties": {
- "key": {
- "type": "string",
- "index": "no"
- },
- "value": {
- "type": "string",
- "index": "no"
- }
- }
- }
- }
- }
-}
+++ /dev/null
-{
- "rule": {
- "_id": {
- "path": "id"
- },
- "properties": {
- "id": {
- "type": "integer",
- "index": "not_analyzed"
- },
- "key": {
- "type": "string",
- "index": "not_analyzed"
- },
- "language": {
- "type": "string",
- "index": "not_analyzed"
- },
- "name": {
- "type": "multi_field",
- "fields": {
- "name": { "type": "string", "index": "analyzed" },
- "raw": { "type": "string", "index": "not_analyzed"}
- }
- },
- "description": {
- "type": "string",
- "index": "no"
- },
- "parentKey": {
- "type": "string",
- "index": "not_analyzed"
- },
- "repositoryKey": {
- "type": "string",
- "index": "not_analyzed"
- },
- "severity": {
- "type": "string",
- "index": "not_analyzed"
- },
- "status": {
- "type": "string",
- "index": "not_analyzed"
- },
- "cardinality": {
- "type": "string",
- "index": "no"
- },
- "createdAt": {
- "type": "date",
- "format": "date_optional_time"
- },
- "updatedAt": {
- "type": "date",
- "format": "date_optional_time"
- },
- "note": {
- "properties": {
- "data": {
- "type": "string",
- "index": "no"
- },
- "userLogin": {
- "type": "string",
- "index": "no"
- },
- "createdAt": {
- "type": "date",
- "format": "date_optional_time"
- },
- "updatedAt": {
- "type": "date",
- "format": "date_optional_time"
- }
- }
- },
- "params": {
- "properties": {
- "key": {
- "type": "string",
- "index": "no"
- },
- "type": {
- "type": "string",
- "index": "no"
- },
- "defaultValue": {
- "type": "string",
- "index": "no"
- },
- "description": {
- "type": "string",
- "index": "no"
- }
- }
- },
- "systemTags": {
- "type": "string",
- "index": "not_analyzed"
- },
- "adminTags": {
- "type": "string",
- "index": "not_analyzed"
- }
- }
- }
-}
--- /dev/null
+{
+ "active_rule": {
+ "_id": {
+ "path": "id"
+ },
+ "_parent": {
+ "type": "rule"
+ },
+ "properties": {
+ "id": {
+ "type": "integer",
+ "index": "not_analyzed"
+ },
+ "severity": {
+ "type": "string",
+ "index": "not_analyzed"
+ },
+ "profileId": {
+ "type": "integer",
+ "index": "not_analyzed"
+ },
+ "parentId": {
+ "type": "integer",
+ "index": "not_analyzed"
+ },
+ "inheritance": {
+ "type": "string",
+ "index": "not_analyzed"
+ },
+ "note": {
+ "properties": {
+ "data": {
+ "type": "string",
+ "index": "no"
+ },
+ "userLogin": {
+ "type": "string",
+ "index": "no"
+ },
+ "createdAt": {
+ "type": "date",
+ "format": "date_optional_time"
+ },
+ "updatedAt": {
+ "type": "date",
+ "format": "date_optional_time"
+ }
+ }
+ },
+ "params": {
+ "properties": {
+ "key": {
+ "type": "string",
+ "index": "no"
+ },
+ "value": {
+ "type": "string",
+ "index": "no"
+ }
+ }
+ }
+ }
+ }
+}
--- /dev/null
+{
+ "rule": {
+ "_id": {
+ "path": "id"
+ },
+ "properties": {
+ "id": {
+ "type": "integer",
+ "index": "not_analyzed"
+ },
+ "key": {
+ "type": "string",
+ "index": "not_analyzed"
+ },
+ "language": {
+ "type": "string",
+ "index": "not_analyzed"
+ },
+ "name": {
+ "type": "multi_field",
+ "fields": {
+ "name": { "type": "string", "index": "analyzed" },
+ "raw": { "type": "string", "index": "not_analyzed"}
+ }
+ },
+ "description": {
+ "type": "string",
+ "index": "no"
+ },
+ "parentKey": {
+ "type": "string",
+ "index": "not_analyzed"
+ },
+ "repositoryKey": {
+ "type": "string",
+ "index": "not_analyzed"
+ },
+ "severity": {
+ "type": "string",
+ "index": "not_analyzed"
+ },
+ "status": {
+ "type": "string",
+ "index": "not_analyzed"
+ },
+ "cardinality": {
+ "type": "string",
+ "index": "no"
+ },
+ "createdAt": {
+ "type": "date",
+ "format": "date_optional_time"
+ },
+ "updatedAt": {
+ "type": "date",
+ "format": "date_optional_time"
+ },
+ "note": {
+ "properties": {
+ "data": {
+ "type": "string",
+ "index": "no"
+ },
+ "userLogin": {
+ "type": "string",
+ "index": "no"
+ },
+ "createdAt": {
+ "type": "date",
+ "format": "date_optional_time"
+ },
+ "updatedAt": {
+ "type": "date",
+ "format": "date_optional_time"
+ }
+ }
+ },
+ "params": {
+ "properties": {
+ "key": {
+ "type": "string",
+ "index": "no"
+ },
+ "type": {
+ "type": "string",
+ "index": "no"
+ },
+ "defaultValue": {
+ "type": "string",
+ "index": "no"
+ },
+ "description": {
+ "type": "string",
+ "index": "no"
+ }
+ }
+ },
+ "systemTags": {
+ "type": "string",
+ "index": "not_analyzed"
+ },
+ "adminTags": {
+ "type": "string",
+ "index": "not_analyzed"
+ }
+ }
+ }
+}
*/
package org.sonar.server.rule;
-import org.sonar.server.es.SearchIndex;
-import org.sonar.server.es.SearchNode;
-
import com.github.tlrx.elasticsearch.test.EsSetup;
import org.apache.commons.io.IOUtils;
import org.elasticsearch.client.Requests;
+import org.elasticsearch.common.settings.ImmutableSettings;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.sonar.api.config.Settings;
import org.sonar.api.rule.Severity;
import org.sonar.core.profiling.Profiling;
+import org.sonar.server.es.SearchIndex;
+import org.sonar.server.es.SearchNode;
import org.sonar.server.qualityprofile.Paging;
import org.sonar.server.qualityprofile.QProfileRule;
import org.sonar.test.TestUtils;
@Before
public void setUp() throws Exception {
- esSetup = new EsSetup();
+ esSetup = new EsSetup(ImmutableSettings.builder()
+ .loadFromUrl(SearchNode.class.getResource("config/elasticsearch.json"))
+ .build()
+ );
esSetup.execute(EsSetup.deleteAll());
SearchNode searchNode = mock(SearchNode.class);
package org.sonar.server.rule;
-import org.sonar.server.es.SearchIndex;
-import org.sonar.server.es.SearchNode;
-
import com.github.tlrx.elasticsearch.test.EsSetup;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableList;
import org.apache.commons.io.IOUtils;
import org.apache.ibatis.session.SqlSession;
import org.elasticsearch.common.collect.Lists;
+import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.search.SearchHit;
import org.junit.After;
import org.junit.Before;
import org.sonar.core.qualityprofile.db.ActiveRuleDto;
import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
import org.sonar.core.rule.*;
+import org.sonar.server.es.SearchIndex;
+import org.sonar.server.es.SearchNode;
import org.sonar.test.TestUtils;
import java.io.IOException;
public void setUp() throws Exception {
when(myBatis.openSession()).thenReturn(session);
- esSetup = new EsSetup();
+ esSetup = new EsSetup(ImmutableSettings.builder().loadFromUrl(SearchNode.class.getResource("config/elasticsearch.json")).build());
esSetup.execute(EsSetup.deleteAll());
SearchNode node = mock(SearchNode.class);