@@ -27,23 +27,17 @@ class ElasticQuery implements \Spameri\ElasticQuery\Entity\ArrayInterface
2727 private $ aggregation ;
2828
2929 /**
30- * @var ?int
30+ * @var \Spameri\ElasticQuery\Options
3131 */
32- private $ from ;
33-
34- /**
35- * @var ?int
36- */
37- private $ size ;
32+ private $ options ;
3833
3934
4035 public function __construct (
4136 ?\Spameri \ElasticQuery \Query \QueryCollection $ query = NULL
4237 , ?\Spameri \ElasticQuery \Filter \FilterCollection $ filter = NULL
4338 , ?\Spameri \ElasticQuery \Options \SortCollection $ sort = NULL
4439 , ?\Spameri \ElasticQuery \Aggregation \AggregationCollection $ aggregation = NULL
45- , ?int $ from = NULL
46- , ?int $ size = NULL
40+ , ?Options $ options = NULL
4741 )
4842 {
4943 if ( ! $ query ) {
@@ -58,12 +52,14 @@ public function __construct(
5852 if ( ! $ aggregation ) {
5953 $ aggregation = new \Spameri \ElasticQuery \Aggregation \AggregationCollection ();
6054 }
55+ if ( ! $ options ) {
56+ $ options = new Options ();
57+ }
6158 $ this ->query = $ query ;
6259 $ this ->filter = $ filter ;
6360 $ this ->sort = $ sort ;
6461 $ this ->aggregation = $ aggregation ;
65- $ this ->from = $ from ;
66- $ this ->size = $ size ;
62+ $ this ->options = $ options ;
6763 }
6864
6965
@@ -79,9 +75,21 @@ public function filter() : \Spameri\ElasticQuery\Filter\FilterCollection
7975 }
8076
8177
78+ public function aggregation () : \Spameri \ElasticQuery \Aggregation \AggregationCollection
79+ {
80+ return $ this ->aggregation ;
81+ }
82+
83+
84+ public function options () : \Spameri \ElasticQuery \Options
85+ {
86+ return $ this ->options ;
87+ }
88+
89+
8290 public function toArray () : array
8391 {
84- $ array = [] ;
92+ $ array = $ this -> options -> toArray () ;
8593
8694 $ queryArray = $ this ->query ->toArray ();
8795 if ($ queryArray ) {
@@ -103,14 +111,6 @@ public function toArray() : array
103111 $ array ['aggs ' ] = $ aggregation ;
104112 }
105113
106- if ($ this ->size !== NULL ) {
107- $ array ['size ' ] = $ this ->size ;
108- }
109-
110- if ($ this ->from !== NULL ) {
111- $ array ['from ' ] = $ this ->from ;
112- }
113-
114114 return $ array ;
115115 }
116116
0 commit comments