title: Spring Data MongoDb Query malformed SpEL
body: <p>Hi I want to run the following query to filter items, the problem is in the second expression where I want to filter the filenames that match some pattern in the list, but it is giving me the following error for that second expression.</p>
  <blockquote>
  <p>Expression [ #fileNames == null or #fileNames.isEmpty() ? {$expr : 'true'} : { $expr: { $gt: [ { $size: { $filter: { input: #fileNames, as: 'pattern', cond: { $regexMatch: { input: '$fileName', regex: '$$pattern' } } } } }, 0 ] } } ] @212: EL1043E: Unexpected token. Expected 'rsquare(])' but was 'comma(,)'</p>
  </blockquote>
  <p>This expression works in mongoDb directly, so what would be the correct way to write this Query?</p>
  <pre class="lang-java prettyprint-override"><code>@Query(&quot;{ $and :[&quot;
      + &quot;?#{ #users == null or #users.isEmpty() ? {$expr : 'true'} : { 'userName' : {$in : #users} } },&quot;
      + &quot;?#{ #fileNamePatterns== null or #fileNamePatterns.isEmpty() ? {$expr : 'true'} : { $expr: { $gt: [ { $size: { $filter: { input: #fileNamePatterns, as: 'pattern', cond: { $regexMatch: { input: '$fileName', regex: '$$pattern' } } } } }, 0 ] } } },&quot;
      + &quot;?#{ #from == null ? {$expr : 'true'} : { 'timestamp' : {$gte : #from} } },&quot;
      + &quot;?#{ #to == null ? {$expr : 'true'} : { 'timestamp' : {$lte : #to} } }&quot;
      + &quot;]}&quot;)
  Page&lt;FileHistory&gt; findHistory(List&lt;String&gt; users, List&lt;String&gt; fileNamePatterns, LocalDateTime from, LocalDateTime to, Pageable pageable);
  </code></pre>
  <p>The fields in the entity would be:</p>
  <pre class="lang-java prettyprint-override"><code>public class FileHistory {
  
    @Id
    private ObjectId fileId;
    private String fileName;
    private String userName;
    private LocalDateTime timestamp;
  
  }
  </code></pre>