@@ -21,6 +21,10 @@ class QueryBuilder
2121
2222 private ?int $ size = null ;
2323
24+ private string |array |null $ pit = null ;
25+
26+ private ?array $ searchAfter = null ;
27+
2428 private ?QueryInterface $ query = null ;
2529
2630 private ?array $ fields = null ;
@@ -59,6 +63,24 @@ public function setSize(int $size): self
5963 return $ this ;
6064 }
6165
66+ public function setPit (string |array |null $ pit ): self
67+ {
68+ if (is_array ($ pit ) && !isset ($ pit ['id ' ])) {
69+ throw new \InvalidArgumentException ('Parameter "pit" is not valid. Value with key "id" is not set. ' );
70+ }
71+
72+ $ this ->pit = $ pit ;
73+
74+ return $ this ;
75+ }
76+
77+ public function setSearchAfter (?array $ searchAfter ): self
78+ {
79+ $ this ->searchAfter = $ searchAfter ;
80+
81+ return $ this ;
82+ }
83+
6284 public function setQuery (QueryInterface $ query ): self
6385 {
6486 $ this ->query = $ query ;
@@ -113,6 +135,18 @@ public function build(): array
113135 $ query ['size ' ] = $ this ->size ;
114136 }
115137
138+ if (null !== $ this ->pit ) {
139+ if (is_string ($ this ->pit )) {
140+ $ query ['pit ' ] = ['id ' => $ this ->pit ];
141+ } else {
142+ $ query ['pit ' ] = $ this ->pit ;
143+ }
144+ }
145+
146+ if (null !== $ this ->searchAfter ) {
147+ $ query ['search_after ' ] = $ this ->searchAfter ;
148+ }
149+
116150 if (null !== $ this ->source ) {
117151 $ query ['_source ' ] = $ this ->source ;
118152 }
@@ -155,6 +189,16 @@ public function getSize(): ?int
155189 return $ this ->size ;
156190 }
157191
192+ public function getPit (): string |array |null
193+ {
194+ return $ this ->pit ;
195+ }
196+
197+ public function getSearchAfter (): ?array
198+ {
199+ return $ this ->searchAfter ;
200+ }
201+
158202 public function getQuery (): ?QueryInterface
159203 {
160204 return $ this ->query ;
0 commit comments