@@ -14,23 +14,33 @@ class QueryCollection extends \Spameri\ElasticQuery\Query\AbstractLeafQuery
1414 * @var \Spameri\ElasticQuery\Query\ShouldCollection
1515 */
1616 private $ shouldCollection ;
17+ /**
18+ * @var null|\Spameri\ElasticQuery\Query\MustNotCollection
19+ */
20+ private $ mustNotCollection ;
1721
1822
1923 public function __construct (
2024 ?\Spameri \ElasticQuery \Query \MustCollection $ mustCollection = NULL ,
21- ?\Spameri \ElasticQuery \Query \ShouldCollection $ shouldCollection = NULL
25+ ?\Spameri \ElasticQuery \Query \ShouldCollection $ shouldCollection = NULL ,
26+ ?\Spameri \ElasticQuery \Query \MustNotCollection $ mustNotCollection = NULL
2227 )
2328 {
2429 if ( ! $ mustCollection ) {
2530 $ mustCollection = new \Spameri \ElasticQuery \Query \MustCollection ();
2631 }
2732
33+ if ( ! $ mustNotCollection ) {
34+ $ mustNotCollection = new \Spameri \ElasticQuery \Query \MustNotCollection ();
35+ }
36+
2837 if ( ! $ shouldCollection ) {
2938 $ shouldCollection = new \Spameri \ElasticQuery \Query \ShouldCollection ();
3039 }
3140
3241 $ this ->mustCollection = $ mustCollection ;
3342 $ this ->shouldCollection = $ shouldCollection ;
43+ $ this ->mustNotCollection = $ mustNotCollection ;
3444 }
3545
3646
@@ -59,6 +69,12 @@ public function toArray() : array
5969 foreach ($ this ->mustCollection as $ item ) {
6070 $ array ['bool ' ]['must ' ][] = $ item ->toArray ();
6171 }
72+
73+ /** @var \Spameri\ElasticQuery\Query\AbstractLeafQuery $item */
74+ foreach ($ this ->mustNotCollection as $ item ) {
75+ $ array ['bool ' ]['must_not ' ][] = $ item ->toArray ();
76+ }
77+
6278 /** @var \Spameri\ElasticQuery\Query\AbstractLeafQuery $item */
6379 foreach ($ this ->shouldCollection as $ item ) {
6480 $ array ['bool ' ]['should ' ][] = $ item ->toArray ();
0 commit comments