java - Elasticsearch updating index -


i have problem elastic: when trying update index custom java connector via http put, it's update 2 documents stuck(this document response status 200, can them url). no errors, no response, server become unavailable. , when trying evaluate method idea ide, says "evaluating". problem?

this code connecting , updating index.

import com.fasterxml.jackson.core.jsonprocessingexception; import com.fasterxml.jackson.databind.objectmapper; import org.apache.http.httpresponse; import org.apache.http.client.clientprotocolexception; import org.apache.http.client.httpclient; import org.apache.http.client.methods.httppost; import org.apache.http.client.methods.httpput; import org.apache.http.entity.contenttype; import org.apache.http.entity.stringentity; import org.apache.http.impl.client.httpclientbuilder;  import java.io.ioexception; import java.sql.*; import java.time.duration;   public class connector {  private static string selectall = "select * message"; private static string checkfornull = "select count(*) (select 1 elastic_updates limit 1) t"; private static string getlasttimestamp = "select create_date message order create_date desc limit 1"; private static string getlastupdate = "select last_update elastic_updates order last_update desc limit 1"; private static string url = ("jdbc:postgresql://taggo-prod.cpizgq9tfz51.eu-central-1.rds.amazonaws.com/taggo"); private static string login = ("taggo_admin"); private static string pass = ("welcome2u");  public static void main(string[] args) {     statement statement = null;     connector connector = new connector();     int count = 1;     httpclient httpclient = httpclientbuilder.create().build();     try (connection connection = drivermanager.getconnection(url, login, pass)) {         system.out.println("connected");          statement = connection.createstatement();          resultset numofrecords = statement.executequery(checkfornull);         if (connector.checkfornullvalue(numofrecords)) {             resultset resultset = statement.executequery(selectall);             while (resultset.next()) {                 httpput httpput = new httpput("https://search-tag-go-elastic-5vqc4gnxdl77znhdc53sd4la34.eu-central-1.es.amazonaws.com/message/text/" + count + "?pretty");                 string jsonstring = connector.createmessage(resultset);                 stringentity stringentity = new stringentity(jsonstring, contenttype.application_form_urlencoded);                 httpput.setentity(stringentity);                 httpresponse response = httpclient.execute(httpput);                 system.out.println(response);                 count++;             }             resultset.close();         } else {          }         numofrecords.close();     } catch (sqlexception e) {         e.printstacktrace();     } catch (jsonprocessingexception e) {         e.printstacktrace();     } catch (clientprotocolexception e) {         e.printstacktrace();     } catch (ioexception e) {         e.printstacktrace();     } {         if (statement != null) {             try {                 statement.close();             } catch (sqlexception e) {                 e.printstacktrace();             }         }     } }  private string createmessage(resultset resultset) throws sqlexception, jsonprocessingexception {     objectmapper mapper = new objectmapper();     message message = new message();     message.setcontent(resultset.getstring("content"));     message.setcreatedate(resultset.getstring("create_date"));     message.setactive(boolean.parseboolean(resultset.getstring("is_active")));     message.setlifetime(duration.ofmillis(resultset.getlong("lifetime") / 1000));     message.setmediacontent(resultset.getstring("media_content"));     string jsonstring = mapper.writevalueasstring(message);     return jsonstring; }  private boolean checkfornullvalue(resultset resultset) {     try {         resultset.next();         string date = resultset.getstring("last_update");         if (date.isempty()) {             return true;         } else {             return false;         }     } catch (sqlexception e) {         e.printstacktrace();     }     return true; } 

}


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -