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;
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());
}
}
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;
}
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) {