File tree 3 files changed +23
-0
lines changed
3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 2
2
2014-03-24
3
3
- Added Filter\Indices #574
4
4
5
+ 2014-03-25
6
+ - Allow json string as data srouce for Bulk\Action on update #575
7
+
5
8
2014-03-20
6
9
- Allow for request params in delete by query calls #573
7
10
Original file line number Diff line number Diff line change @@ -190,6 +190,8 @@ public function toString()
190
190
$ source = $ this ->getSource ();
191
191
if (is_string ($ source )) {
192
192
$ string .= $ source ;
193
+ } elseif (is_array ($ source ) && array_key_exists ('doc ' , $ source ) && is_string ($ source ['doc ' ])) {
194
+ $ string .= '{"doc": ' . $ source ['doc ' ] . '} ' ;
193
195
} else {
194
196
$ string .= json_encode ($ source , JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES );
195
197
}
Original file line number Diff line number Diff line change @@ -558,6 +558,24 @@ public function testUpdate()
558
558
$ doc = $ type ->getDocument (6 );
559
559
$ this ->assertEquals ('test ' , $ doc ->test );
560
560
561
+ //test updating via document with json string as data
562
+ $ doc3 = $ type ->createDocument (2 );
563
+ $ bulk = new Bulk ($ client );
564
+ $ bulk ->setType ($ type );
565
+ $ doc3 ->setData ('{"name" : "Paul it is"} ' );
566
+ $ updateAction = new \Elastica \Bulk \Action \UpdateDocument ($ doc3 );
567
+ $ bulk ->addAction ($ updateAction );
568
+ $ response = $ bulk ->send ();
569
+
570
+ $ this ->assertTrue ($ response ->isOk ());
571
+ $ this ->assertFalse ($ response ->hasError ());
572
+
573
+ $ index ->refresh ();
574
+
575
+ $ doc = $ type ->getDocument (2 );
576
+ $ docData = $ doc ->getData ();
577
+ $ this ->assertEquals ('Paul it is ' , $ docData ['name ' ]);
578
+
561
579
$ index ->delete ();
562
580
}
563
581
You can’t perform that action at this time.
0 commit comments