From: Simon Brandhof Date: Tue, 23 Feb 2016 17:57:41 +0000 (+0100) Subject: Remove useless usage of ES UpsertRequest X-Git-Tag: 5.5-M6~105 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=12e70acc1a8cdcbc5e6af31c4c0ed6894435a75c;p=sonarqube.git Remove useless usage of ES UpsertRequest --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexer.java index 8e606de2c5c..6cb8f5fe74c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexer.java @@ -20,6 +20,7 @@ package org.sonar.server.user.index; import java.util.Iterator; +import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.update.UpdateRequest; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -57,17 +58,16 @@ public class UserIndexer extends BaseIndexer { bulk.start(); while (users.hasNext()) { UserDoc user = users.next(); - bulk.add(newUpsertRequest(user)); + bulk.add(newIndexRequest(user)); maxUpdatedAt = Math.max(maxUpdatedAt, user.updatedAt()); } bulk.stop(); return maxUpdatedAt; } - private static UpdateRequest newUpsertRequest(UserDoc user) { - return new UpdateRequest(UserIndexDefinition.INDEX, UserIndexDefinition.TYPE_USER, user.login()) - .doc(user.getFields()) - .upsert(user.getFields()); + private static IndexRequest newIndexRequest(UserDoc user) { + return new IndexRequest(UserIndexDefinition.INDEX, UserIndexDefinition.TYPE_USER, user.login()) + .source(user.getFields()); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/view/index/ViewIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/view/index/ViewIndexer.java index 5c721ce77d7..296a9cccaf8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/view/index/ViewIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/view/index/ViewIndexer.java @@ -21,7 +21,7 @@ package org.sonar.server.view.index; import java.util.List; import java.util.Map; -import org.elasticsearch.action.update.UpdateRequest; +import org.elasticsearch.action.index.IndexRequest; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -113,16 +113,15 @@ public class ViewIndexer extends BaseIndexer { } private void doIndex(BulkIndexer bulk, ViewDoc viewDoc, boolean needClearCache) { - bulk.add(newUpsertRequest(viewDoc)); + bulk.add(newIndexRequest(viewDoc)); if (needClearCache) { clearLookupCache(viewDoc.uuid()); } } - private static UpdateRequest newUpsertRequest(ViewDoc doc) { - return new UpdateRequest(ViewIndexDefinition.INDEX, ViewIndexDefinition.TYPE_VIEW, doc.uuid()) - .doc(doc.getFields()) - .upsert(doc.getFields()); + private static IndexRequest newIndexRequest(ViewDoc doc) { + return new IndexRequest(ViewIndexDefinition.INDEX, ViewIndexDefinition.TYPE_VIEW, doc.uuid()) + .source(doc.getFields()); } private void clearLookupCache(String viewUuid) {