File tree Expand file tree Collapse file tree 3 files changed +19
-29
lines changed Expand file tree Collapse file tree 3 files changed +19
-29
lines changed Original file line number Diff line number Diff line change @@ -39,35 +39,17 @@ public function addSubAggregation(AggregationInterface $subAggregation): self
39
39
40
40
public function toRequestArray (): array
41
41
{
42
- $ request = [
43
- $ this ->name => $ this ->data ,
42
+ $ aggregationArray = [
43
+ $ this ->name => $ this ->data
44
44
];
45
45
46
- if (!empty ($ this ->subAggregations )) {
47
- foreach ($ this ->subAggregations as $ subAggregation ) {
48
- $ request [$ this ->name ]['aggs ' ][$ subAggregation ->getName ()] = $ this ->handleSubAggregationData ($ subAggregation );
49
- }
46
+ foreach ($ this ->subAggregations as $ subAggregation ) {
47
+ $ aggregationArray [$ this ->name ]['aggs ' ] = array_merge (
48
+ $ aggregationArray [$ this ->name ]['aggs ' ] ?? [],
49
+ $ subAggregation ->toRequestArray ()
50
+ );
50
51
}
51
52
52
- return $ request ;
53
- }
54
-
55
- private function handleSubAggregationData (Aggregation $ aggregation ): array
56
- {
57
- $ request = $ aggregation ->getData ();
58
-
59
- if (!empty ($ aggregation ->subAggregations )) {
60
- foreach ($ aggregation ->subAggregations as $ subAggregation ) {
61
- $ subAggregationData = $ subAggregation ->getData ();
62
-
63
- $ request ['aggs ' ][$ subAggregation ->getName ()] = $ subAggregationData ;
64
-
65
- if (!empty ($ subAggregation ->getSubAggregations ())) {
66
- $ subAggregationData ['aggs ' ] = $ this ->handleSubAggregationData ($ subAggregation );
67
- }
68
- }
69
- }
70
-
71
- return $ request ;
53
+ return $ aggregationArray ;
72
54
}
73
55
}
Original file line number Diff line number Diff line change @@ -113,6 +113,14 @@ public function whereIn(string $field, array $values): self
113
113
return $ this ;
114
114
}
115
115
116
+ public function whereNotIn (string $ field , array $ values ): self
117
+ {
118
+ $ this ->query ['bool ' ]['must_not ' ][]['terms ' ][$ field ] = $ values ;
119
+
120
+ return $ this ;
121
+ }
122
+
123
+
116
124
public function orWhereIn (string $ field , array $ values ): self
117
125
{
118
126
$ this ->query ['bool ' ]['should ' ][]['terms ' ][$ field ] = $ values ;
@@ -433,7 +441,7 @@ public function getQuery(): array
433
441
434
442
public function getSort (): array
435
443
{
436
- return $ this ->sort ;
444
+ return $ this ->sort ?? [] ;
437
445
}
438
446
439
447
public function getSelect (): array
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public function addMany(array $documents): self
37
37
38
38
public function getDocuments (): array
39
39
{
40
- return $ this ->documents ;
40
+ return $ this ->documents ?? [] ;
41
41
}
42
42
43
43
/**
@@ -55,7 +55,7 @@ public function toRequestJson(): string
55
55
$ body [] = json_encode ($ document , JSON_THROW_ON_ERROR );
56
56
}
57
57
58
- return join (PHP_EOL , $ body ) . PHP_EOL ;
58
+ return implode (PHP_EOL , $ body ) . PHP_EOL ;
59
59
}
60
60
61
61
/*
You can’t perform that action at this time.
0 commit comments