]> source.dussan.org Git - sonarqube.git/commitdiff
Remove useless source field "_parent" in ES doc "issues"
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 23 Feb 2016 17:57:24 +0000 (18:57 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 26 Feb 2016 13:29:39 +0000 (14:29 +0100)
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java

index 60c0ed205361548244edfca0a9b53ac0a6374521..48d17194db940927b1d98ce1b3781e8c597b2b2b 100644 (file)
@@ -21,8 +21,8 @@ package org.sonar.server.issue.index;
 
 import java.util.Iterator;
 import javax.annotation.Nullable;
+import org.elasticsearch.action.index.IndexRequest;
 import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.action.update.UpdateRequest;
 import org.elasticsearch.index.query.FilterBuilders;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.sonar.db.DbClient;
@@ -83,7 +83,7 @@ public class IssueIndexer extends BaseIndexer {
     long maxDate = 0L;
     while (issues.hasNext()) {
       IssueDoc issue = issues.next();
-      bulk.add(newUpsertRequest(issue));
+      bulk.add(newIndexRequest(issue));
 
       // it's more efficient to sort programmatically than in SQL on some databases (MySQL for instance)
       maxDate = Math.max(maxDate, issue.getTechnicalUpdateDate().getTime());
@@ -112,17 +112,13 @@ public class IssueIndexer extends BaseIndexer {
     return bulk;
   }
 
-  private UpdateRequest newUpsertRequest(IssueDoc issue) {
+  private IndexRequest newIndexRequest(IssueDoc issue) {
     String projectUuid = issue.projectUuid();
 
-    // type of parent doc is "authorization"
-    issue.setField("_parent", projectUuid);
-
-    return new UpdateRequest(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE, issue.key())
+    return new IndexRequest(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE, issue.key())
       .routing(projectUuid)
       .parent(projectUuid)
-      .doc(issue.getFields())
-      .upsert(issue.getFields());
+      .source(issue.getFields());
   }
 
 }