From 2a72de1ddb8f961ab5568272cb291f71ec395aa1 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 23 Feb 2016 18:57:24 +0100 Subject: [PATCH] Remove useless source field "_parent" in ES doc "issues" --- .../org/sonar/server/issue/index/IssueIndexer.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java index 60c0ed20536..48d17194db9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java @@ -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()); } } -- 2.39.5