title: convert _id(ObjectId) to String in aggregation for lookup Spring boot
body: <p><strong>THIS IS NOT QUESTION</strong></p>
  <p>I had a problem for a long time to convert objectId to string in spring boot aggregation and I can't find any useful way to solve it.
  finally, I figure out and I like to share my way to those who have the same problem;
  As you know lookup need two sides of lookup the same value, for example, two sides objectId or two sides string
  if you have objecteId and string in another side you have to make this objectId to string and then write your lookup stage;
  the stage before lookup should be the project stage with usage of $toString expression like bellow:</p>
  <pre><code>ProjectionOperation projectionOperation = Aggregation.project(/*your nedded fields */)
  .and(ConvertOperators.ToString.toString(&quot;$_id)).as(&quot;aggId&quot;);
  </code></pre>
  <p>and then you can use lookup easily like below:</p>
  <pre><code>Aggregation agg = Aggregation.newAggregation(
                  Aggregation.match(
                          Criteria.where(&quot;cratorId&quot;).is(userId)
                  )
                  ,
                  projectionOperation
                  ,
                  Aggregation.lookup(&quot;post&quot;, &quot;aggId&quot;, &quot;courseId&quot;, &quot;postList&quot;),
  </code></pre>
  <p>my full aggregation is:</p>
  <pre><code>ProjectionOperation projectionOperation = Aggregation.project(/*your nedded fields */)
  .and(ConvertOperators.ToString.toString(&quot;$_id&quot;)).as(&quot;aggId&quot;);
  
  Aggregation agg = Aggregation.newAggregation(
                  Aggregation.match(
                          Criteria.where(&quot;creatorId&quot;).is(userId)
                  )
                  ,
                  projectionOperation
                  ,
                  Aggregation.lookup(&quot;post&quot;, &quot;aggId&quot;, &quot;courseId&quot;, &quot;postList&quot;)
  );
  
  return this.aggregate(agg, entityClass, Object.class).getMappedResults();
  </code></pre>
  <p>hope it can be useful</p>