title: Mongodb lookup for not equal fields
body: <p>I want to join two collections and find the documents where has one equal field and one unequal field!
  This is what I was tried, But not work</p>
  <pre><code>db.collectionOne.aggregate[
      {
          &quot;$match&quot;: {
              &quot;$and&quot;: [
                  { &quot;$text&quot;: { &quot;$search&quot;: &quot;this is my query&quot; } },
                  { &quot;b&quot;: { &quot;$eq&quot;: &quot;60e849054d2f0d409041b6a2&quot; } }
              ]
          }
      },
      { &quot;$addFields&quot;: { &quot;pID&quot;: { &quot;$toString&quot;: &quot;$_id&quot; }, &quot;score&quot;: { &quot;$meta&quot;: &quot;textScore&quot; } } },
      {
          &quot;$lookup&quot;: {
              &quot;from&quot;: &quot;collectionsTwo&quot;,
              &quot;as&quot;: &quot;collectionsTwoName&quot;,
              &quot;pipeline&quot;: [{
                  &quot;$match&quot;: {
                      &quot;$expr&quot;: {
                          &quot;$and&quot;: [{
                              &quot;$ne&quot;: [&quot;$fieldOne&quot;, &quot;60dd0f98d10f072e2a225502&quot;] // This one is unqual field
                          }, { &quot;$eq&quot;: [&quot;$pID&quot;, &quot;$fieldTwo&quot;] }] // This one is equal field
                      }
                  }
              }]
          }
      },
      { &quot;$sort&quot;: { &quot;score&quot;: -1 } },
      { &quot;$limit&quot;: 1 }
  ])
  </code></pre>