Skip to content

Use index operation instead of create #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public int getElasticSearchVersion() {
JSONObject elasticSearchConfig = new JSONObject(responseBody);
JSONObject version = (JSONObject) elasticSearchConfig.get("version");
String elasticVersion = version.get("number").toString();
if (Objects.equals(version.get("distribution").toString(), "opensearch")) {
if (Objects.equals(JsonUtils.getValueOrNull(version, "distribution"), "opensearch")) {
elasticSearchVersion = 7;
}else{
elasticSearchVersion = Integer.parseInt(elasticVersion.split("\\.")[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ public class ElasticSearchRequests {
/**
* Request to send metrics (JMeter/Percentiles) as ElasticSearch documents
*/
public static String SEND_BULK_REQUEST = "{ \"create\" : { \"_index\" : \"%s\" } }%n";
public static String SEND_BULK_REQUEST = "{ \"index\" : { \"_index\" : \"%s\" } }%n";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.github.delirius325.jmeter.backendlistener.elasticsearch;

import org.json.JSONObject;

import java.net.HttpRetryException;

public class JsonUtils {
public static <T> T getValueOrNull(JSONObject object, String key) {
try {
return (T) object.get(key);
} catch (Exception e) {
return null;
}
}
}