File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -148,8 +148,10 @@ public function updateDocument($data, array $options = array())
148
148
throw new InvalidException ('Document or Script id is not set ' );
149
149
}
150
150
151
+ $ id = urlencode ($ data ->getId ());
152
+
151
153
return $ this ->getIndex ()->getClient ()->updateDocument (
152
- $ data -> getId () ,
154
+ $ id ,
153
155
$ data ,
154
156
$ this ->getIndex ()->getName (),
155
157
$ this ->getName (),
Original file line number Diff line number Diff line change @@ -565,6 +565,32 @@ public function testUpdateDocument()
565
565
$ this ->assertEquals (3 , $ updatedDoc ['counter ' ], "Counter was not incremented " );
566
566
}
567
567
568
+ public function testUpdateDocumentWithIdForwardSlashes ()
569
+ {
570
+ $ client = $ this ->_getClient ();
571
+ $ index = $ client ->getIndex ('elastica_test ' );
572
+ $ type = $ index ->getType ('update_type ' );
573
+ $ id = '/id/with/forward/slashes ' ;
574
+ $ type ->addDocument (new Document ($ id , array ('name ' => 'bruce wayne batman ' , 'counter ' => 1 )));
575
+ $ newName = 'batman ' ;
576
+
577
+ $ document = new Document ();
578
+ $ script = new Script (
579
+ "ctx._source.name = name; ctx._source.counter += count " ,
580
+ array (
581
+ 'name ' => $ newName ,
582
+ 'count ' => 2 ,
583
+ ),
584
+ null ,
585
+ $ id
586
+ );
587
+ $ script ->setUpsert ($ document );
588
+
589
+ $ type ->updateDocument ($ script , array ('refresh ' => true ));
590
+ $ updatedDoc = $ type ->getDocument ($ id )->getData ();
591
+ $ this ->assertEquals ($ newName , $ updatedDoc ['name ' ], "Name was not updated " );
592
+ $ this ->assertEquals (3 , $ updatedDoc ['counter ' ], "Counter was not incremented " );
593
+ }
568
594
public function testUpdateDocumentWithParameter ()
569
595
{
570
596
$ client = $ this ->_getClient ();
You can’t perform that action at this time.
0 commit comments