Skip to content
Snippets Groups Projects
Commit 09804fed authored by Mykyta Savchuk's avatar Mykyta Savchuk
Browse files

use IndexRequest to update the record

parent 05e6e0e2
No related branches found
No related tags found
1 merge request!488use Index API to update the record
Pipeline #169846 failed
......@@ -399,17 +399,10 @@ public class IndexerServiceImpl implements IndexerService {
jaxRsDpsLog.warning(String.format("data not found for record: %s", record));
}
OperationType operation = record.getOperationType();
Map<String, Object> sourceMap = getSourceMap(record);
String index = this.elasticIndexNameResolver.getIndexNameFromKind(record.getKind());
if (operation == OperationType.create) {
IndexRequest indexRequest = new IndexRequest(index).id(record.getId()).source(this.gson.toJson(sourceMap), XContentType.JSON);
bulkRequest.add(indexRequest);
} else if (operation == OperationType.update) {
UpdateRequest updateRequest = new UpdateRequest(index, "_doc", record.getId()).doc(this.gson.toJson(sourceMap), XContentType.JSON).docAsUpsert(true);
bulkRequest.add(updateRequest);
}
IndexRequest indexRequest = new IndexRequest(index).id(record.getId()).source(this.gson.toJson(sourceMap), XContentType.JSON);
bulkRequest.add(indexRequest);
}
return processBulkRequest(restClient, bulkRequest);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment