title: How to project map & reduce in ProjectionOperation in Spring Data MongoDB?
body: <p>I can not able to do <code>map</code> and <code>reduce</code> operation in java mongodb in ProjectionOperation.</p>
  <p>I have project operation in native <code>mongo query</code> like this:</p>
  <pre><code>{
      $project: {
          data: {
              $map: {
                  input: params.timeArray,
                  in: {
                      &quot;key&quot;: &quot;$$this&quot;,
                      &quot;value&quot;: { &quot;$cond&quot;: [{ &quot;$in&quot;: [&quot;$$this&quot;, &quot;$data.date&quot;] }, &quot;$data&quot;, []] }
                  }
              }
          }
      }
  }
  </code></pre>
  <p>And I also want to do <code>reduce</code> operation in another projection operation like this:</p>
  <pre><code>{
      $project: {
          id: 1,
          data: { $reduce: { input: &quot;$data&quot;, initialValue: [], in: { $concatArrays: [&quot;$$value&quot;, &quot;$$this&quot;] } } }
      }
  }
  </code></pre>
  <p>I have tried this:</p>
  <pre><code>ProjectionOperation projectionOperation1 = Aggregation.project()
                  .and(VariableOperators.mapItemsOf(&quot;data&quot;/*here, I want to pass timeArray*/)
                          .as(&quot;input&quot;)
                          .andApply(context -&gt; new BasicDBObject(&quot;value&quot;,
                                  ConditionalOperators.when(where(&quot;$$this&quot;).in(&quot;$data.date&quot;))
                                          .then(&quot;$data&quot;)
                                          .otherwise(new HashSet&lt;&gt;()))))
                  .as(&quot;data&quot;);
  </code></pre>
  <p>But it didn't give me desired result.</p>
  <p>I'm using <code>springboot</code> version 1.5.10.RELEASE</p>
  <p>Any help would be appreciated!</p>