Github user cestella commented on a diff in the pull request:
https://github.com/apache/metron/pull/832#discussion_r149413486
--- Diff:
metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/utils/ElasticsearchUtils.java
---
@@ -179,4 +186,46 @@ else if(ipObj instanceof List) {
}
throw new IllegalStateException("Unable to read the elasticsearch ips,
expected es.ip to be either a list of strings, a string hostname or a host:port
string");
}
+
+ /**
+ * Converts an Elasticsearch SearchRequest to JSON.
+ * @param esRequest The search request.
+ * @return The JSON representation of the SearchRequest.
+ */
+ public static String
toJSON(org.elasticsearch.action.search.SearchRequest esRequest) {
+ String json = "null";
--- End diff --
Should we instead return back an `Optional<String>` rather than the string
representation of null on a failure here? Alternatively, maybe throw an
exception so the calling function can handle the exception how it likes?
---