@@ -44,16 +44,14 @@ public boolean sync(String index, String content) throws Exception {
4444 Map <String ,Object > data = jsonToMap (content );
4545 Map <String ,Object > head = jsonToMap ((String ) data .get ("head" ).toString ());
4646 String type = (String ) head .get ("type" ).toString ();
47- String db = (String ) head .get ("db" ).toString ();
48- String table = (String ) head .get ("table" ).toString ();
4947 String id = (String ) head .get ("id" ).toString ();
5048 String text = "" ;
5149 switch (type ) {
5250 case "INSERT" :
5351 text = (String ) data .get ("after" ).toString ();
5452 if (!"" .equals (text )) {
5553 try {
56- return insert ("sync" + "-" + db + "-" + table , "default" , id , text );
54+ return insert (index , "default" , id , text );
5755 } catch (Exception e ) {
5856 throw new Exception ("elasticsearch insert fail" , e );
5957 }
@@ -63,7 +61,7 @@ public boolean sync(String index, String content) throws Exception {
6361 text = (String ) data .get ("after" ).toString ();
6462 if (!"" .equals (id )) {
6563 try {
66- return update ("sync" + "-" + db + "-" + table , "default" , id , text );
64+ return update (index , "default" , id , text );
6765 } catch (Exception e ) {
6866 throw new Exception ("elasticsearch update fail" , e );
6967 }
@@ -72,7 +70,7 @@ public boolean sync(String index, String content) throws Exception {
7270 case "DELETE" :
7371 if (!"" .equals (id )) {
7472 try {
75- return delete ("sync" + "-" + db + "-" + table , "default" , id );
73+ return delete (index , "default" , id );
7674 } catch (Exception e ) {
7775
7876 }
@@ -101,9 +99,6 @@ public static Map<String,Object> jsonToMap(String jsonObj) {
10199 * @throws Exception
102100 */
103101 public boolean insert (String index , String type , String id , String content ) throws Exception {
104- if (!index ("sync-sdsw-sys_log" )) {
105- System .out .println (setMappings ("sync-sdsw-sys_log" ));
106- }
107102 Map <String , String > params = Collections .emptyMap ();
108103 HttpEntity entity = new NStringEntity (content , ContentType .APPLICATION_JSON );
109104 Response response = rs .performRequest ("PUT" , "/" + index + "/" + type + "/" + id , params , entity );
@@ -119,9 +114,6 @@ public boolean insert(String index, String type, String id, String content) thro
119114 * @throws Exception
120115 */
121116 public boolean update (String index , String type , String id , String content ) throws Exception {
122- if (!index ("sync-sdsw-sys_log" )) {
123- System .out .println (setMappings ("sync-sdsw-sys_log" ));
124- }
125117 Map <String , String > params = Collections .emptyMap ();
126118 HttpEntity entity = new NStringEntity (content , ContentType .APPLICATION_JSON );
127119 Response response = rs .performRequest ("PUT" , "/" + index + "/" + type + "/" + id , params , entity );
0 commit comments