diff --git a/pom.xml b/pom.xml
index 2166330..13fe1dc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,6 +38,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.elasticsearch.client
+ x-pack-transport
+ 6.4.2
+
org.springframework.boot
@@ -116,6 +121,17 @@
false
+
+
+ elastic
+ https://artifacts.elastic.co/maven
+
+ true
+
+
+ false
+
+
diff --git a/src/main/java/com/manalejandro/arjion/ESConfig.java b/src/main/java/com/manalejandro/arjion/ESConfig.java
index 3684273..7c6c9df 100644
--- a/src/main/java/com/manalejandro/arjion/ESConfig.java
+++ b/src/main/java/com/manalejandro/arjion/ESConfig.java
@@ -1,11 +1,15 @@
package com.manalejandro.arjion;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
+
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
+import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -36,15 +40,36 @@ public class ESConfig {
private String documentType;
private TransportClient client;
+
+ String clusterId = "2be3ffc1fd284a8788906e5022d0cb18"; // Your cluster ID here
+ String region = "eu-central-1"; // Your region here
+ boolean enableSsl = true;
@Bean
- public Client client() throws Exception {
+ public Client client() {
+ Settings settings = Settings.builder()
+ .put("client.transport.nodes_sampler_interval", "5s")
+ .put("client.transport.sniff", false)
+ .put("transport.tcp.compress", true)
+ .put("cluster.name", EsClusterName)
+ .put("xpack.security.transport.ssl.enabled", enableSsl)
+ .put("request.headers.X-Found-Cluster", clusterId)
+ .put("xpack.security.user", "elastic:ypRPLpSMYrEQ5Pm5HL6zePWD")
+ .put("xpack.security.transport.ssl.verification_mode", "full")
+ .build();
- Settings esSettings = Settings.builder().put("cluster.name", EsClusterName).put("node.name", EsNodeName)
- .build();
-
- client = new PreBuiltTransportClient(esSettings);
- return client.addTransportAddress(new TransportAddress(InetAddress.getByName(EsHost), EsPort));
+ String hostname = clusterId + "." + region + ".aws.cloud.es.io";
+ // Instantiate a TransportClient and add the cluster to the list of addresses to connect to.
+ // Only port 9343 (SSL-encrypted) is currently supported.
+ TransportClient client = null;
+ try {
+ client = new PreBuiltXPackTransportClient(settings)
+ .addTransportAddress(new TransportAddress(InetAddress.getByName(hostname), 9343));
+ } catch (UnknownHostException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return client;
}
@Bean
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index d57275f..c26680b 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,12 +1,12 @@
server.servlet.context-path=/arjion
-server.port=8080
-elasticsearch.clustername=elasticsearch
-elasticsearch.host=localhost
-elasticsearch.port=9300
+server.port=3117
+elasticsearch.clustername=2be3ffc1fd284a8788906e5022d0cb18
+elasticsearch.host=2be3ffc1fd284a8788906e5022d0cb18.eu-central-1.aws.cloud.es.io
+elasticsearch.port=9343
elasticsearch.nodename=arjion
arjion.indexName=documentos
arjion.documentType=documento
-arjion.uploadpath=/upload/
+arjion.uploadpath=/home/ale/upload/
arjion.tesseractpath=/usr/bin
arjion.tesseractdatapath=/usr/share/tesseract-ocr
spring.main.allow-bean-definition-overriding=true