update= new Update.Builder(updateQuery.toJSONString()).index(completeIndexName) .type(indexType).id(id).build();
update= new Update.Builder(updateQuery.toJSONString()).index(completeIndexName) .type(indexAndType.getType()).id(id).build();
update= new Update.Builder(updateQuery.toJSONString()).index(completeIndexName) .type(indexAndType.getType()).id(id).build();
docMap.put("script", script); String json = mapper.writeValueAsString(docMap); return new Update.Builder(json).index(parentDoc.getIndex()).type(parentDoc.getType()).id(parentDoc.getId()).build(); } catch (JsonProcessingException e) { e.printStackTrace();
String payload = resultsMapper.getEntityMapper().mapToString(payLoadMap); Update.Builder updateBuilder = new Update.Builder(payload).index(indexName).type(type).id(query.getId()); return updateBuilder.build(); } catch (IOException e) { throw new ElasticsearchException("failed to index the document [id: " + query.getId() + "]", e);
public void bulkUpdate(List<JsonObject> updates, String docType){ final Bulk.Builder bulkProcessor = new Bulk.Builder(); //prepare update actions updates.forEach( u -> { final String id = u.remove("_id").getAsString(); final String index = u.remove("_index").getAsString(); final JsonObject updateDoc = new JsonObject(); updateDoc.add("doc",u.getAsJsonObject()); final Update update = new Update .Builder(updateDoc.toString()) .index(index) .id(id) .type(docType).build(); bulkProcessor.addAction(update); }); final JestClient client = getElasticSearchClient(); try { bulkUpdate(bulkProcessor, 0, client); } catch (InterruptedException e) { log.error("Error executing bulk update: {}", e.getMessage(),e); throw new RuntimeException("Error executing bulk update: " + e.getMessage(), e); } }
private Map<IndexId, Update> updateRequests(Node node) { HashMap<IndexId, Update> reqs = new HashMap<>(); for (Label l: node.getLabels()) { if (!indexLabels.contains(l.name())) continue; for (ElasticSearchIndexSpec spec: indexSettings.getIndexSpec().get(l.name())) { String id = id(node), indexName = spec.getIndexName(); reqs.put(new IndexId(indexName, id), new Update.Builder(nodeToJson(node, spec.getProperties())) .type(l.name()) .index(spec.getIndexName()) .id(id(node)) .build()); } } return reqs; }
/** * Update status of feature. * * @param uid * feature id * @param enable * enabler */ public Update updateStatus(String uid, boolean enable) { String partialDoc = "{ \"doc\" : { \"enable\" : " + enable + " } }"; return new Update.Builder(partialDoc) // .index(connection.getIndexName()) // .type(ElasticConstants.TYPE_FEATURE) // .id(getFeatureTechId(uid)) // .refresh(true) // .build(); }
public Update queryRemoveFeatureFromGroup(String uid, String groupName) { String partialDoc = "{ \"doc\" : { \"group\" : \"\" } }"; return new Update.Builder(partialDoc) // .index(connection.getIndexName()) // .type(ElasticConstants.TYPE_FEATURE) // .id(getFeatureTechId(uid)) // .build(); }
public Update queryAddFeatureToGroup(String uid, String groupName) { String partialDoc = "{ \"doc\" : { \"group\" : \"" + groupName + "\" } }"; return new Update.Builder(partialDoc) // .index(connection.getIndexName()) // .type(ElasticConstants.TYPE_FEATURE) // .id(getFeatureTechId(uid)) // .build(); }
public Update queryUpdateStatusWithTechId(String _id, boolean enable) { String partialDoc = "{ \"doc\" : { \"enable\" : " + enable + " } }"; return new Update.Builder(partialDoc) // .index(connection.getIndexName()) // .type(ElasticConstants.TYPE_FEATURE) // .id(_id) // .build(); }