@@ -94,6 +94,14 @@ protected function filterProperty(string $property, $value, Builder $aggregation
94
94
95
95
$ caseSensitive = true ;
96
96
97
+ $ strategy = $ this ->properties [$ property ] ?? self ::STRATEGY_EXACT ;
98
+
99
+ // prefixing the strategy with i makes it case insensitive
100
+ if (0 === strpos ($ strategy , 'i ' )) {
101
+ $ strategy = substr ($ strategy , 1 );
102
+ $ caseSensitive = false ;
103
+ }
104
+
97
105
if ($ metadata ->hasField ($ field ) && !$ metadata ->hasAssociation ($ field )) {
98
106
if ('id ' === $ field ) {
99
107
$ values = array_map ([$ this , 'getIdFromValue ' ], $ values );
@@ -107,17 +115,10 @@ protected function filterProperty(string $property, $value, Builder $aggregation
107
115
return ;
108
116
}
109
117
110
- $ strategy = $ this ->properties [$ property ] ?? self ::STRATEGY_EXACT ;
111
-
112
- // prefixing the strategy with i makes it case insensitive
113
- if (0 === strpos ($ strategy , 'i ' )) {
114
- $ strategy = substr ($ strategy , 1 );
115
- $ caseSensitive = false ;
116
- }
117
-
118
118
$ inValues = [];
119
+ $ type = $ metadata ->getTypeOfField ($ field );
119
120
foreach ($ values as $ inValue ) {
120
- $ inValues [] = $ this ->addEqualityMatchStrategy ($ strategy , $ field , $ inValue , $ caseSensitive , $ metadata );
121
+ $ inValues [] = $ this ->addEqualityMatchStrategy ($ strategy , $ field , $ inValue , $ caseSensitive , $ type );
121
122
}
122
123
123
124
$ aggregationBuilder
@@ -149,10 +150,15 @@ protected function filterProperty(string $property, $value, Builder $aggregation
149
150
return ;
150
151
}
151
152
153
+ $ inValues = [];
154
+ foreach ($ values as $ inValue ) {
155
+ $ inValues [] = $ this ->addEqualityMatchStrategy ($ strategy , $ field , $ inValue , $ caseSensitive , $ doctrineTypeField );
156
+ }
157
+
152
158
$ aggregationBuilder
153
159
->match ()
154
160
->field ($ matchField )
155
- ->in ($ values );
161
+ ->in ($ inValues );
156
162
}
157
163
158
164
/**
@@ -162,10 +168,8 @@ protected function filterProperty(string $property, $value, Builder $aggregation
162
168
*
163
169
* @return Regex|string
164
170
*/
165
- private function addEqualityMatchStrategy (string $ strategy , string $ field , $ value , bool $ caseSensitive , ClassMetadata $ metadata )
171
+ private function addEqualityMatchStrategy (string $ strategy , string $ field , $ value , bool $ caseSensitive , string $ type )
166
172
{
167
- $ type = $ metadata ->getTypeOfField ($ field );
168
-
169
173
switch ($ strategy ) {
170
174
case MongoDbType::STRING !== $ type :
171
175
return MongoDbType::getType ($ type )->convertToDatabaseValue ($ value );
0 commit comments