File tree Expand file tree Collapse file tree 1 file changed +22
-9
lines changed
examples/esql-article/src/main/java/co/elastic/clients/esql/article Expand file tree Collapse file tree 1 file changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -143,22 +143,35 @@ public static void main(String[] args) throws IOException, SQLException {
143
143
144
144
System .out .println ("Finished in: " + Duration .between (start , end ).toMillis () + "\n " );
145
145
146
- String query =
146
+ String queryAuthor =
147
147
"""
148
- from books
149
- | where author == "Isaac Asimov"
150
- | sort year desc
148
+ from books
149
+ | where author == "Isaac Asimov"
150
+ | sort year desc
151
151
| limit 10
152
- """ ;
153
- List <Book > queryRes = (List <Book >) client .esql ().query (ObjectsEsqlAdapter .of (Book .class ), query );
152
+ """ ;
154
153
155
- System . out . println ( "~~~ \n Object result: \n " + queryRes . stream (). map ( Book :: title ). collect ( Collectors . joining ( " \n " )) );
154
+ List < Book > queryRes = ( List < Book >) client . esql (). query ( ObjectsEsqlAdapter . of ( Book . class ), queryAuthor );
156
155
157
- ResultSet resultSet = client . esql ().query ( ResultSetEsqlAdapter . INSTANCE , query );
156
+ System . out . println ( "~~~ \n Object result author: \n " + queryRes . stream ().map ( Book :: title ). collect ( Collectors . joining ( " \n " )) );
158
157
159
- System .out .println ("~~~\n ResultSet result:" );
158
+ ResultSet resultSet = client .esql ().query (ResultSetEsqlAdapter .INSTANCE , queryAuthor );
159
+
160
+ System .out .println ("~~~\n ResultSet result author:" );
160
161
while (resultSet .next ()) {
161
162
System .out .println (resultSet .getString ("title" ));
162
163
}
164
+
165
+ String queryPublisher =
166
+ """
167
+ from books
168
+ | where publisher == "Penguin"
169
+ | sort ratings desc
170
+ | limit 10
171
+ | sort title asc
172
+ """ ;
173
+
174
+ queryRes = (List <Book >) client .esql ().query (ObjectsEsqlAdapter .of (Book .class ), queryPublisher );
175
+ System .out .println ("~~~\n Object result publisher:\n " + queryRes .stream ().map (Book ::title ).collect (Collectors .joining ("\n " )));
163
176
}
164
177
}
You can’t perform that action at this time.
0 commit comments