File tree Expand file tree Collapse file tree 3 files changed +50
-26
lines changed Expand file tree Collapse file tree 3 files changed +50
-26
lines changed Original file line number Diff line number Diff line change @@ -985,13 +985,15 @@ public function scroll($params = array())
985
985
{
986
986
$ scrollID = $ this ->extractArgument ($ params , 'scroll_id ' );
987
987
$ body = $ this ->extractArgument ($ params , 'body ' );
988
+ $ scroll = $ this ->extractArgument ($ params , 'scroll ' );
988
989
989
990
/** @var callback $endpointBuilder */
990
991
$ endpointBuilder = $ this ->endpoints ;
991
992
992
993
/** @var \Elasticsearch\Endpoints\Scroll $endpoint */
993
994
$ endpoint = $ endpointBuilder ('Scroll ' );
994
995
$ endpoint ->setScrollID ($ scrollID )
996
+ ->setScroll ($ scroll )
995
997
->setBody ($ body );
996
998
$ endpoint ->setParams ($ params );
997
999
@@ -1015,11 +1017,10 @@ public function clearScroll($params = array())
1015
1017
/** @var callback $endpointBuilder */
1016
1018
$ endpointBuilder = $ this ->endpoints ;
1017
1019
1018
- /** @var \Elasticsearch\Endpoints\Scroll $endpoint */
1019
- $ endpoint = $ endpointBuilder ('Scroll ' );
1020
+ /** @var \Elasticsearch\Endpoints\ClearScroll $endpoint */
1021
+ $ endpoint = $ endpointBuilder ('ClearScroll ' );
1020
1022
$ endpoint ->setScrollID ($ scrollID )
1021
- ->setBody ($ body )
1022
- ->setClearScroll (true );
1023
+ ->setBody ($ body );
1023
1024
$ endpoint ->setParams ($ params );
1024
1025
1025
1026
return $ this ->performRequest ($ endpoint );
Original file line number Diff line number Diff line change 16
16
class ClearScroll extends AbstractEndpoint
17
17
{
18
18
// A comma-separated list of scroll IDs to clear
19
- private $ scroll_id ;
19
+ private $ scrollId ;
20
20
21
21
/**
22
22
* @param $scroll_id
23
23
*
24
24
* @return $this
25
25
*/
26
- public function setScroll_Id ( $ scroll_id )
26
+ public function setScrollId ( $ scrollId )
27
27
{
28
- if (isset ($ scroll_id ) !== true ) {
28
+ if (isset ($ scrollId ) !== true ) {
29
29
return $ this ;
30
30
}
31
31
32
- $ this ->scroll_id = $ scroll_id ;
32
+ $ this ->scrollId = $ scrollId ;
33
33
34
34
return $ this ;
35
35
}
@@ -40,19 +40,38 @@ public function setScroll_Id($scroll_id)
40
40
*/
41
41
public function getURI ()
42
42
{
43
- if (isset ($ this ->scroll_id ) !== true ) {
44
- throw new Exceptions \RuntimeException (
45
- 'scroll_id is required for Clearscroll '
46
- );
47
- }
48
- $ scroll_id = $ this ->scroll_id ;
49
- $ uri = "/_search/scroll/ $ scroll_id " ;
43
+ return "/_search/scroll/ " ;
44
+ }
50
45
51
- if (isset ($ scroll_id ) === true ) {
52
- $ uri = "/_search/scroll/ $ scroll_id " ;
46
+ /**
47
+ * @param array $body
48
+ *
49
+ * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException
50
+ * @return $this
51
+ */
52
+ public function setBody ($ body )
53
+ {
54
+ if (isset ($ body ) !== true ) {
55
+ return $ this ;
53
56
}
54
57
55
- return $ uri ;
58
+ $ this ->body = $ body ;
59
+
60
+ return $ this ;
61
+ }
62
+
63
+ /**
64
+ * @return array
65
+ */
66
+ public function getBody ()
67
+ {
68
+ if (isset ($ this ->body )) {
69
+ return $ this ->body ;
70
+ }
71
+ if (is_array ($ this ->scrollId )) {
72
+ return ['scroll_id ' => $ this ->scrollId ];
73
+ }
74
+ return ['scroll_id ' => [$ this ->scrollId ]];
56
75
}
57
76
58
77
/**
Original file line number Diff line number Diff line change 15
15
*/
16
16
class Scroll extends AbstractEndpoint
17
17
{
18
- private $ clear = false ;
19
18
20
19
/**
21
20
* @param array $body
@@ -42,9 +41,18 @@ public function getBody()
42
41
return $ this ->body ;
43
42
}
44
43
45
- public function setClearScroll ($ clear )
44
+ /**
45
+ * @param $scroll
46
+ *
47
+ * @return $this
48
+ */
49
+ public function setScroll ($ scroll )
46
50
{
47
- $ this ->clear = $ clear ;
51
+ if (isset ($ scroll ) !== true ) {
52
+ return $ this ;
53
+ }
54
+
55
+ $ this ->body ['scroll ' ] = $ scroll ;
48
56
49
57
return $ this ;
50
58
}
@@ -60,7 +68,7 @@ public function setScrollId($scroll_id)
60
68
return $ this ;
61
69
}
62
70
63
- $ this ->body = $ scroll_id ;
71
+ $ this ->body [ ' scroll_id ' ] = $ scroll_id ;
64
72
65
73
return $ this ;
66
74
}
@@ -89,10 +97,6 @@ public function getParamWhitelist()
89
97
*/
90
98
public function getMethod ()
91
99
{
92
- if ($ this ->clear == true ) {
93
- return 'DELETE ' ;
94
- }
95
-
96
100
return 'GET ' ;
97
101
}
98
102
}
You can’t perform that action at this time.
0 commit comments