@@ -396,6 +396,46 @@ public function testDeleteByQueryWithQuery()
396
396
$ this ->assertEquals (0 , $ response ->count ());
397
397
}
398
398
399
+ public function testDeleteByQueryWithQueryAndOptions ()
400
+ {
401
+ $ index = $ this ->_createIndex ('test ' , true , 2 );
402
+ $ type = new Type ($ index , 'test ' );
403
+ $ type ->addDocument (new Document (1 , array ('name ' => 'ruflin nicolas ' )));
404
+ $ type ->addDocument (new Document (2 , array ('name ' => 'ruflin ' )));
405
+ $ index ->refresh ();
406
+
407
+ $ response = $ index ->search ('ruflin* ' );
408
+ $ this ->assertEquals (2 , $ response ->count ());
409
+
410
+ $ response = $ index ->search ('nicolas ' );
411
+ $ this ->assertEquals (1 , $ response ->count ());
412
+
413
+ // Route to the wrong document id; should not delete
414
+ $ response = $ type ->deleteByQuery (new SimpleQueryString ('nicolas ' ), array ('routing ' =>'2 ' ));
415
+ $ this ->assertTrue ($ response ->isOk ());
416
+
417
+ $ index ->refresh ();
418
+
419
+ $ response = $ index ->search ('ruflin* ' );
420
+ $ this ->assertEquals (2 , $ response ->count ());
421
+
422
+ $ response = $ index ->search ('nicolas ' );
423
+ $ this ->assertEquals (1 , $ response ->count ());
424
+
425
+ // Delete first document
426
+ $ response = $ type ->deleteByQuery (new SimpleQueryString ('nicolas ' ), array ('routing ' =>'1 ' ));
427
+ $ this ->assertTrue ($ response ->isOk ());
428
+
429
+ $ index ->refresh ();
430
+
431
+ // Makes sure, document is deleted
432
+ $ response = $ index ->search ('ruflin* ' );
433
+ $ this ->assertEquals (1 , $ response ->count ());
434
+
435
+ $ response = $ index ->search ('nicolas ' );
436
+ $ this ->assertEquals (0 , $ response ->count ());
437
+ }
438
+
399
439
/**
400
440
* Test to see if Elastica_Type::getDocument() is properly using
401
441
* the fields array when available instead of _source
0 commit comments