Skip to content

Commit

Permalink
I think it is a missing slash after all.
Browse files Browse the repository at this point in the history
# Conflicts:
#	vpro-shared-elasticsearch-client/src/main/java/nl/vpro/elasticsearchclient/IndexHelper.java
  • Loading branch information
mihxil committed Dec 13, 2024
1 parent 6dad20a commit 4f132c9
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,10 @@ public final ObjectNode sendEntity(String method, String path, HttpEntity entity
c.accept(req);
}
log.debug("Posting to {}", path);
return read(client().performRequest(req));

var response = client().performRequest(req);

return read(response);
} catch (IOException e) {
log.error(e.getMessage(), e);
throw new RuntimeException(e);
Expand Down Expand Up @@ -688,7 +691,7 @@ public ObjectNode index(String id, Object o) {

public ObjectNode index(String id, byte[] o) {
HttpEntity entity = entity(o);
return postEntity(indexPath(id), entity(o));
return putEntity(indexPath(id), entity);
}

public ObjectNode index(String id, Object o, Consumer<ObjectNode> sourceConsumer) {
Expand All @@ -701,7 +704,7 @@ public ObjectNode index(String id, Object o, Consumer<ObjectNode> sourceConsumer
/**
*/
public ObjectNode indexWithRouting(String id, byte[] o, String routing) {
return postEntity(indexPath(id), entity(o), req -> req.addParameter(ROUTING, routing));
return putEntity(indexPath(id), entity(o), req -> req.addParameter(ROUTING, routing));
}

/**
Expand Down Expand Up @@ -734,7 +737,7 @@ protected String indexPath(String id) {
}

protected String _indexPath(String type, @Nullable String id, @Nullable String parent) {
String path = getIndexName() + "/" + type + (id == null ? "" : ("/" + encode(id)));
String path = '/' + getIndexName() + "/" + type + (id == null ? "" : ("/" + encode(id)));
if (parent != null) {
path += "?parent=" + parent;
}
Expand Down Expand Up @@ -811,7 +814,7 @@ public Optional<JsonNode> get(String id){
ArrayNode docs = objectNode.withArray("docs");

for (JsonNode n : docs) {
boolean found = n.get("found").asBoolean();
boolean found = n.has("found") && n.get("found").asBoolean();
if (found) {
result.add(Optional.of(n));
} else {
Expand Down Expand Up @@ -1112,7 +1115,11 @@ protected static HttpEntity bulkEntity(Collection<BulkRequestEntry> request) {
static protected String saveToString(JsonNode jsonNode) {
String value = jsonNode.toString();
return value.replaceAll("\\p{Cc}", "");
}

@SneakyThrows
static protected byte[] saveToArray(JsonNode jsonNode) {
return LENIENT.writer().writeValueAsBytes(jsonNode);
}

@Override
Expand Down

0 comments on commit 4f132c9

Please sign in to comment.