egalpin commented on a change in pull request #14347:
URL: https://github.com/apache/beam/pull/14347#discussion_r616999346
##########
File path:
sdks/java/io/elasticsearch/src/main/java/org/apache/beam/sdk/io/elasticsearch/ElasticsearchIO.java
##########
@@ -303,6 +341,73 @@ public static ConnectionConfiguration create(String[]
addresses, String index, S
.build();
}
+ /**
+ * Creates a new Elasticsearch connection configuration with no default
type.
+ *
+ * @param addresses list of addresses of Elasticsearch nodes
+ * @param index the index toward which the requests will be issued
+ * @return the connection configuration object
+ */
+ public static ConnectionConfiguration create(String[] addresses, String
index) {
+ checkArgument(addresses != null, "addresses can not be null");
+ checkArgument(addresses.length > 0, "addresses can not be empty");
+ checkArgument(index != null, "index can not be null");
+ return new AutoValue_ElasticsearchIO_ConnectionConfiguration.Builder()
+ .setAddresses(Arrays.asList(addresses))
+ .setIndex(index)
+ .setType("")
+ .setTrustSelfSignedCerts(false)
+ .build();
+ }
+
+ /**
+ * Creates a new Elasticsearch connection configuration with no default
index nor type.
+ *
+ * @param addresses list of addresses of Elasticsearch nodes
+ * @return the connection configuration object
+ */
+ public static ConnectionConfiguration create(String[] addresses) {
+ checkArgument(addresses != null, "addresses can not be null");
+ checkArgument(addresses.length > 0, "addresses can not be empty");
+ return new AutoValue_ElasticsearchIO_ConnectionConfiguration.Builder()
+ .setAddresses(Arrays.asList(addresses))
+ .setIndex("")
+ .setType("")
+ .setTrustSelfSignedCerts(false)
+ .build();
+ }
+
+ /**
+ * Generates the bulk API endpoint based on the set values.
+ *
+ * <p>Based on ConnectionConfiguration constructors, we know that one of
the following is true:
+ *
+ * <ul>
+ * <li>index and type are non-empty strings
+ * <li>index is non-empty string, type is empty string
+ * <li>index and type are empty string
+ * </ul>
+ *
+ * <p>Valid endpoints therefore include:
+ *
+ * <ul>
+ * <li>/_bulk
+ * <li>/index_name/_bulk
+ * <li>/index_name/type_name/_bulk
+ * </ul>
+ */
+ public String getBulkEndPoint() {
Review comment:
I just went to check the API docs and it looks like there's mention of
the 3 formats in the 1.x docs[1] ¯\\\_(ツ)_/¯ This should help alleviate some
compatibility issues with ES 8.x where the notion of `type` will be fully
removed.
[1]
https://www.elastic.co/guide/en/elasticsearch/reference/1.7/docs-bulk.html#docs-bulk
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]