Skip to content

Commit

Permalink
fix testSoftDelete
Browse files Browse the repository at this point in the history
Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
  • Loading branch information
nknize committed Feb 23, 2022
1 parent cf63070 commit b20b9a2
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -951,30 +951,30 @@ public void testSoftDeletes() throws Exception {
int numDocs = between(10, 100);
for (int i = 0; i < numDocs; i++) {
String doc = Strings.toString(JsonXContent.contentBuilder().startObject().field("field", "v1").endObject());
Request request = new Request("POST", "/" + index + "/" + type + "/" + i);
Request request = new Request("POST", "/" + index + "/_doc/" + i);
request.setJsonEntity(doc);
client().performRequest(request);
refresh();
refreshAllIndices();
}
client().performRequest(new Request("POST", "/" + index + "/_flush"));
int liveDocs = numDocs;
assertTotalHits(liveDocs, entityAsMap(client().performRequest(new Request("GET", "/" + index + "/_search"))));
for (int i = 0; i < numDocs; i++) {
if (randomBoolean()) {
String doc = Strings.toString(JsonXContent.contentBuilder().startObject().field("field", "v2").endObject());
Request request = new Request("POST", "/" + index + "/" + type + "/" + i);
Request request = new Request("POST", "/" + index + "/_doc/" + i);
request.setJsonEntity(doc);
client().performRequest(request);
} else if (randomBoolean()) {
client().performRequest(new Request("DELETE", "/" + index + "/" + type + "/" + i));
client().performRequest(new Request("DELETE", "/" + index + "/_doc/" + i));
liveDocs--;
}
}
refresh();
refreshAllIndices();
assertTotalHits(liveDocs, entityAsMap(client().performRequest(new Request("GET", "/" + index + "/_search"))));
saveInfoDocument(index + "_doc_count", Integer.toString(liveDocs));
} else {
int liveDocs = Integer.parseInt(loadInfoDocument("doc_count"));
int liveDocs = Integer.parseInt(loadInfoDocument(index + "_doc_count"));
assertTotalHits(liveDocs, entityAsMap(client().performRequest(new Request("GET", "/" + index + "/_search"))));
}
}
Expand Down

0 comments on commit b20b9a2

Please sign in to comment.