11package com .es .app ;
22
33
4- import com .es .util .ESManager ;
54import com .es .service .CountService ;
65import com .es .service .DataService ;
6+ import com .es .service .DeleteService ;
7+ import com .es .service .IngestService ;
8+ import com .es .util .ESManager ;
79import org .elasticsearch .client .Client ;
810
911
@@ -15,6 +17,8 @@ public static void main(String[] args) {
1517
1618 CountService countService = new CountService (client );
1719 DataService dataService = new DataService (client );
20+ IngestService ingestService = new IngestService (client );
21+ DeleteService deleteService = new DeleteService (client );
1822
1923 //count
2024 System .out .println ("\n getMatchAllQueryCount from ES::: " + countService .getMatchAllQueryCount ());
@@ -23,21 +27,41 @@ public static void main(String[] args) {
2327
2428
2529 // Data
26- System .out .println ("\n getMatchAllQueryData from ES::: " );
27- dataService .getMatchAllQueryData ().forEach (item ->System .out .println (item ));
28-
29- System .out .println ("\n getBoolQueryData from ES::: " );
30- dataService .getBoolQueryData ().forEach (item ->System .out .println (item ));
31-
32- System .out .println ("\n getPhraseQueryData from ES::: " );
33- dataService .getPhraseQueryData ().forEach (item ->System .out .println (item ));
34-
30+ System .out .println ("\n getMatchAllQueryData from ES::: " );
31+ dataService .getMatchAllQueryData ().forEach (item -> System .out .println (item ));
32+
33+ System .out .println ("\n getBoolQueryData from ES::: " );
34+ dataService .getBoolQueryData ().forEach (item -> System .out .println (item ));
35+
36+ System .out .println ("\n getPhraseQueryData from ES::: " );
37+ dataService .getPhraseQueryData ().forEach (item -> System .out .println (item ));
38+
39+ //Ingest
40+ String json1 = "{" +
41+ "\" name\" :\" skyji\" ," +
42+ "\" job\" :\" Admin\" ," +
43+ "\" location\" :\" India\" " +
44+ "}" ;
45+
46+ String json2 = "{" +
47+ "\" name\" :\" jom\" ," +
48+ "\" job\" :\" assiant\" ," +
49+ "\" location\" :\" Meana\" " +
50+ "}" ;
51+ // ingest single record
52+ // System.out.println("\nIngestService response::: " +ingestService.ingest("tweet",json) );
53+
54+ // ingest batch of records
55+ // System.out.println("\nIngestService response::: " + ingestService.ingest("tweet", Arrays.asList(json1, json2)));
56+
57+
58+ // Delete
59+ // delete one record by id
60+ //System.out.println("delete by id " + deleteService.delete("AVSMh1LBWlqOklhqtVNs"));
61+ //delete record by query
62+ System .out .println ("delete by query " + deleteService .deleteByQuery ("satendra" ));
3563 client .close ();
3664
37-
38-
39-
4065 }
4166
42-
4367}
0 commit comments