@Override public UpdateRequest createUpdateRequest( String index, String docType, String key, XContentType contentType, byte[] document) { return new UpdateRequest(index, docType, key) .doc(document, contentType) .upsert(document, contentType); }
private static UpdateRequest createUpdateRequest(Tuple2<String, String> element, ParameterTool parameterTool) { Map<String, Object> json = new HashMap<>(); json.put("data", element.f1); return new UpdateRequest( parameterTool.getRequired("index"), parameterTool.getRequired("type"), element.f0) .doc(json) .upsert(json); } }
private static UpdateRequest createUpdateRequest(Tuple2<String, String> element, ParameterTool parameterTool) { Map<String, Object> json = new HashMap<>(); json.put("data", element.f1); return new UpdateRequest( parameterTool.getRequired("index"), parameterTool.getRequired("type"), element.f0) .doc(json) .upsert(json); } }
private static UpdateRequest createUpdateRequest(Tuple2<String, String> element, ParameterTool parameterTool) { Map<String, Object> json = new HashMap<>(); json.put("data", element.f1); return new UpdateRequest( parameterTool.getRequired("index"), parameterTool.getRequired("type"), element.f0) .doc(json) .upsert(json); } }
private static UpdateRequest createUpdateRequest(Tuple2<String, String> element, ParameterTool parameterTool) { Map<String, Object> json = new HashMap<>(); json.put("data", element.f1); return new UpdateRequest( parameterTool.getRequired("index"), parameterTool.getRequired("type"), element.f0) .doc(json) .upsert(json); } }
@Override public void indexTask(Task task) { try { String id = task.getTaskId(); TaskSummary summary = new TaskSummary(task); byte[] doc = objectMapper.writeValueAsBytes(summary); UpdateRequest req = new UpdateRequest(indexName, TASK_DOC_TYPE, id); req.doc(doc, XContentType.JSON); req.upsert(doc, XContentType.JSON); updateWithRetry(req, "Index workflow into doc_type workflow"); } catch (Exception e) { logger.error("Failed to index task: {}", task.getTaskId(), e); } }
@Override public void indexWorkflow(Workflow workflow) { try { String id = workflow.getWorkflowId(); WorkflowSummary summary = new WorkflowSummary(workflow); byte[] doc = objectMapper.writeValueAsBytes(summary); UpdateRequest req = new UpdateRequest(indexName, WORKFLOW_DOC_TYPE, id); req.doc(doc, XContentType.JSON); req.upsert(doc, XContentType.JSON); req.retryOnConflict(5); updateWithRetry(req, "Index workflow into doc_type workflow"); } catch (Exception e) { logger.error("Failed to index workflow: {}", workflow.getWorkflowId(), e); } }
@Override public void addEventExecution(EventExecution eventExecution) { try { byte[] doc = objectMapper.writeValueAsBytes(eventExecution); String id = eventExecution.getName() + "." + eventExecution.getEvent() + "." + eventExecution .getMessageId() + "." + eventExecution.getId(); UpdateRequest req = new UpdateRequest(logIndexName, EVENT_DOC_TYPE, id); req.doc(doc, XContentType.JSON); req.upsert(doc, XContentType.JSON); req.retryOnConflict(5); updateWithRetry(req, "Update Event execution for doc_type event"); } catch (Exception e) { logger.error("Failed to index event execution: {}", eventExecution.getId(), e); } }
/** * Sets the doc source of the update request to be used when the document does not exists. */ public UpdateRequestBuilder setUpsert(Map source, XContentType contentType) { request.upsert(source, contentType); return this; }
/** * Sets the doc source of the update request to be used when the document does not exists. */ public UpdateRequestBuilder setUpsert(byte[] source, XContentType xContentType) { request.upsert(source, xContentType); return this; }
/** * Sets the doc source of the update request to be used when the document does not exists. */ public UpdateRequestBuilder setUpsert(XContentBuilder source) { request.upsert(source); return this; }
/** * Sets the doc source of the update request to be used when the document does not exists. */ public UpdateRequestBuilder setUpsert(String source, XContentType xContentType) { request.upsert(source, xContentType); return this; }
/** * Sets the doc source of the update request to be used when the document does not exists. The doc * includes field and value pairs. */ public UpdateRequestBuilder setUpsert(Object... source) { request.upsert(source); return this; }
/** * Sets the doc source of the update request to be used when the document does not exists. The doc * includes field and value pairs. */ public UpdateRequestBuilder setUpsert(XContentType xContentType, Object... source) { request.upsert(xContentType, source); return this; }
/** * Sets the index request to be used if the document does not exists. Otherwise, a * {@link org.elasticsearch.index.engine.DocumentMissingException} is thrown. */ public UpdateRequestBuilder setUpsert(IndexRequest indexRequest) { request.upsert(indexRequest); return this; }
/** * Sets the doc source of the update request to be used when the document does not exists. */ public UpdateRequestBuilder setUpsert(Map source) { request.upsert(source); return this; }
/** * Sets the doc source of the update request to be used when the document does not exists. */ public UpdateRequestBuilder setUpsert(byte[] source, int offset, int length, XContentType xContentType) { request.upsert(source, offset, length, xContentType); return this; }
/** * Sets the doc source of the update request to be used when the document does not exists. */ public UpdateRequestBuilder setUpsert(byte[] source, int offset, int length, XContentType xContentType) { request.upsert(source, offset, length, xContentType); return this; }
/** * Sets the doc source of the update request to be used when the document does not exists. The doc * includes field and value pairs. */ public UpdateRequestBuilder setUpsert(XContentType xContentType, Object... source) { request.upsert(xContentType, source); return this; }
/** * Sets the doc source of the update request to be used when the document does not exists. * @deprecated use {@link #setUpsert(byte[], int, int, XContentType)} */ @Deprecated public UpdateRequestBuilder setUpsert(byte[] source, int offset, int length) { request.upsert(source, offset, length); return this; }