diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-10-19 10:29:51 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-10-19 16:31:46 +0200 |
commit | 760bbafc902e846a14213f687407a8cd275f8f64 (patch) | |
tree | 8c704df9368023f544b1d232fef1fb7d9f8cee52 | |
parent | 626904d85efc720c070885b19cb74ee86f4ecc8d (diff) | |
download | sonarqube-760bbafc902e846a14213f687407a8cd275f8f64.tar.gz sonarqube-760bbafc902e846a14213f687407a8cd275f8f64.zip |
Use doc_values on some fields of ES index issues/issue
That decreases memory pressure on the aggreagation and sorting
requests involving these fields.
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java | 9 | ||||
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java | 16 |
2 files changed, 17 insertions, 8 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java b/server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java index 7f9a599cba0..127c77e5a3d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java @@ -178,6 +178,15 @@ public class NewIndex { this.fieldName = fieldName; } + /** + * It is recommended to enable doc_values when the non-analyzed field is involved + * into aggregations/sorting and only a small fraction of the values is used (high + * number of different values) + * <ul> + * <li>https://www.elastic.co/blog/found-sizing-elasticsearch</li> + * <li>https://www.elastic.co/guide/en/elasticsearch/guide/current/doc-values.html</li> + * </ul> + */ public StringFieldBuilder docValues() { this.docValues = true; return this; diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java index 0157b9539ea..a5c8c3e15f5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java @@ -107,11 +107,11 @@ public class IssueIndexDefinition implements IndexDefinition { issueMapping.setAttribute("_id", ImmutableMap.of("path", FIELD_ISSUE_KEY)); issueMapping.setAttribute("_parent", ImmutableMap.of("type", TYPE_AUTHORIZATION)); issueMapping.setAttribute("_routing", ImmutableMap.of("required", true, "path", FIELD_ISSUE_PROJECT_UUID)); - issueMapping.stringFieldBuilder(FIELD_ISSUE_ACTION_PLAN).build(); + issueMapping.stringFieldBuilder(FIELD_ISSUE_ACTION_PLAN).docValues().build(); issueMapping.stringFieldBuilder(FIELD_ISSUE_ASSIGNEE).enableSorting().build(); - issueMapping.stringFieldBuilder(FIELD_ISSUE_ATTRIBUTES).disableSearch().build(); - issueMapping.stringFieldBuilder(FIELD_ISSUE_AUTHOR_LOGIN).build(); - issueMapping.stringFieldBuilder(FIELD_ISSUE_COMPONENT_UUID).build(); + issueMapping.stringFieldBuilder(FIELD_ISSUE_ATTRIBUTES).docValues().disableSearch().build(); + issueMapping.stringFieldBuilder(FIELD_ISSUE_AUTHOR_LOGIN).docValues().build(); + issueMapping.stringFieldBuilder(FIELD_ISSUE_COMPONENT_UUID).docValues().build(); issueMapping.createLongField(FIELD_ISSUE_DEBT); issueMapping.createDoubleField(FIELD_ISSUE_EFFORT); issueMapping.stringFieldBuilder(FIELD_ISSUE_FILE_PATH).enableSorting().build(); @@ -121,12 +121,12 @@ public class IssueIndexDefinition implements IndexDefinition { issueMapping.stringFieldBuilder(FIELD_ISSUE_KEY).enableSorting().build(); issueMapping.stringFieldBuilder(FIELD_ISSUE_LANGUAGE).build(); issueMapping.createIntegerField(FIELD_ISSUE_LINE); - issueMapping.stringFieldBuilder(FIELD_ISSUE_MESSAGE).build(); - issueMapping.stringFieldBuilder(FIELD_ISSUE_MODULE_UUID).build(); + issueMapping.stringFieldBuilder(FIELD_ISSUE_MESSAGE).docValues().build(); + issueMapping.stringFieldBuilder(FIELD_ISSUE_MODULE_UUID).docValues().build(); issueMapping.createUuidPathField(FIELD_ISSUE_MODULE_PATH); issueMapping.stringFieldBuilder(FIELD_ISSUE_PROJECT_UUID).enableSorting().build(); - issueMapping.stringFieldBuilder(FIELD_ISSUE_DIRECTORY_PATH).build(); - issueMapping.stringFieldBuilder(FIELD_ISSUE_REPORTER).build(); + issueMapping.stringFieldBuilder(FIELD_ISSUE_DIRECTORY_PATH).docValues().build(); + issueMapping.stringFieldBuilder(FIELD_ISSUE_REPORTER).docValues().build(); issueMapping.stringFieldBuilder(FIELD_ISSUE_RESOLUTION).build(); issueMapping.stringFieldBuilder(FIELD_ISSUE_RULE_KEY).build(); issueMapping.stringFieldBuilder(FIELD_ISSUE_SEVERITY).build(); |