@@ -268,8 +268,8 @@ protected Client getClient() {
268
268
testSimpleFacets ();
269
269
}
270
270
271
- @ Test public void testFailedSearch () throws Exception {
272
- logger .info ("Start Testing failed search" );
271
+ @ Test public void testFailedSearchWithWrongQuery () throws Exception {
272
+ logger .info ("Start Testing failed search with wrong query " );
273
273
try {
274
274
client .search (searchRequest ("test" ).source (Unicode .fromStringAsBytes ("{ xxx }" ))).actionGet ();
275
275
assert false : "search should fail" ;
@@ -280,6 +280,28 @@ protected Client getClient() {
280
280
logger .info ("Done Testing failed search" );
281
281
}
282
282
283
+ @ Test public void testFailedSearchWithWrongFrom () throws Exception {
284
+ logger .info ("Start Testing failed search with wrong from" );
285
+ SearchSourceBuilder source = searchSource ()
286
+ .query (termQuery ("multi" , "test" ))
287
+ .from (1000 ).size (20 ).explain (true );
288
+ SearchResponse response = client .search (searchRequest ("test" ).searchType (DFS_QUERY_AND_FETCH ).source (source )).actionGet ();
289
+ assertThat (response .hits ().hits ().length , equalTo (0 ));
290
+
291
+ response = client .search (searchRequest ("test" ).searchType (QUERY_THEN_FETCH ).source (source )).actionGet ();
292
+ assertThat (response .shardFailures ().length , equalTo (0 ));
293
+ assertThat (response .hits ().hits ().length , equalTo (0 ));
294
+
295
+ response = client .search (searchRequest ("test" ).searchType (DFS_QUERY_AND_FETCH ).source (source )).actionGet ();
296
+ assertThat (response .shardFailures ().length , equalTo (0 ));
297
+ assertThat (response .hits ().hits ().length , equalTo (0 ));
298
+
299
+ response = client .search (searchRequest ("test" ).searchType (DFS_QUERY_THEN_FETCH ).source (source )).actionGet ();
300
+ assertThat (response .shardFailures ().length , equalTo (0 ));
301
+ assertThat (response .hits ().hits ().length , equalTo (0 ));
302
+
303
+ logger .info ("Done Testing failed search" );
304
+ }
283
305
284
306
private void index (Client client , String id , String nameValue , int age ) throws IOException {
285
307
client .index (Requests .indexRequest ("test" ).type ("type1" ).id (id ).source (source (id , nameValue , age ))).actionGet ();
0 commit comments