title: How do I create a Partial Index with an $in in the filter expression?
body: <p>I'm basically trying to create a unique partial filter in my collection with a filter that I know works, but MongoDB doesn't accept it.</p>
  <p>Here is my statement:</p>
  <pre class="lang-js prettyprint-override"><code>db.payments.createIndex(
    {
        &quot;userId&quot;: 1,
        &quot;accountId&quot;: 1,
        &quot;status&quot;: 1
    },
    {
        unique: true,
        partialFilterExpression: {
            status: { 
                $in: [&quot;new&quot;, &quot;paid&quot;, &quot;excluded&quot;]
            }
        }
  )
  </code></pre>
  <p>And I get this error message:</p>
  <blockquote>
  <p>2021-04-20 18:53:42] com.mongodb.MongoCommandException: Command failed with error 67 (CannotCreateIndex): 'Error in specification { key: { userId: 1, accountId: 1, status: 1 }, name: &quot;userId_1_accountId_1_status_1&quot;, unique: true, partialFilterExpression: { status: { $in: [ &quot;new&quot;, &quot;paid&quot;, &quot;excluded&quot; ] } }, v: 2 } :: caused by :: unsupported expression in partial index: status $in [ &quot;new&quot; &quot;paid&quot; &quot;excluded&quot; ]</p>
  </blockquote>
  <p>If I try to filter it by a single status it works, <em>e.g.</em></p>
  <pre class="lang-js prettyprint-override"><code>{
      partialFilterExpression: {
          status: { 
              $eq: &quot;new&quot; 
          }
      }
  }
  </code></pre>
  <p>However, if I want to have multiple statuses allowed on the index it doesn't work. I couldn't find anything in the documentation stating that an <code>$in</code> expression is not supported. So how can I get this to work?</p>