title: Invalid Query. You cannot use 'array_contains' filters with 'not_in' filters
body: <p>I have a collection named channels.</p>
  <p>Users are added to <strong>userIds</strong> array and the record is also saved to field named <strong>serverId</strong>.</p>
  <p>I just need a list of newly created or updated rows to update to my local room db.</p>
  <p>I update <strong>snapshotTime</strong> field every time any changes occurs.</p>
  <p>Previously I used the following code, where <em>lastTime is the max(snapshotTime) of local room db</em></p>
  <pre><code>FirestoreUtil.chatChannelCollectionRef
      .whereArrayContains(&quot;userIds&quot;, currentUserId)
      //.whereGreaterThan(&quot;snapshotTime&quot;, lastTime)
      .orderBy(&quot;snapshotTime&quot;, Query.Direction.ASCENDING)
      .startAfter(lastTime)
      .addSnapshotListener (activity) { snapshots, e -&gt;
          if (e != null) {
              Log.e(&quot;exception occurred&quot;, &quot;&quot;)
              return@addSnapshotListener
          }
  
          for (dc in snapshots!!.documentChanges) {
              when (dc.type) {
                  DocumentChange.Type.ADDED -&gt; {
                      val chatChannel = dc.document.toObject(ChatChannel::class.java)
                      chatChannel.serverId = dc.document.id
                      repository.insertOrUpdateChannel(channelDao, chatChannel)
                      Log.e(TAG, &quot;ADDED chatChannel: ${dc.document.data} - ${dc.document.id}&quot;)
                  }
                  DocumentChange.Type.MODIFIED -&gt; {
                      val chatChannel = dc.document.toObject(ChatChannel::class.java)
                      chatChannel.serverId = dc.document.id
                      repository.insertOrUpdateChannel(channelDao, chatChannel)
                      Log.e(TAG, &quot;MODIFIED chatChannel: ${dc.document.data} - ${dc.document.id}&quot;)
                  }
                  DocumentChange.Type.REMOVED -&gt; {
                      val chatChannel = dc.document.toObject(ChatChannel::class.java)
                      chatChannel.serverId = dc.document.id
                      //MessageDatabase.getDatabase(AjoowebApplication.applicationContext()).runInTransaction {
                      repository.deleteChannel(channelDao, chatChannel)
                      Log.e(TAG, &quot;REMOVED chatChannel: ${dc.document.data} - ${dc.document.id}&quot;)
                  }
                  else -&gt; {
                      Log.e(TAG, &quot;MISSING: ${dc.document.data} - ${dc.document.id}&quot;)
                  }
              }
          }
      }
  </code></pre>
  <p>which returns the updated fields but not the new records.</p>
  <p>So I tried this query to get the new rows only:</p>
  <p><em>here channels is a list with all channelsId in local db</em></p>
  <pre><code>FirestoreUtil.firestoreInstance
      .collection(FBCollections.CHANNEL_COL)
      .whereNotIn(&quot;serverId&quot;, channels)
      .whereArrayContains(&quot;userIds&quot;, currentUserId)
      .get()
      .addOnSuccessListener (activity) { snapshots -&gt;
          for (dc in snapshots!!.documents) {
              val chatChannel = dc.toObject(ChatChannel::class.java)!!
              chatChannel.serverId = dc.id
              repository.insertOrUpdateChannel(channelDao, chatChannel)
              Log.e(TAG, &quot;LOADED chatChannel: ${dc.data} - ${dc.id}&quot;)
          }
      }
  </code></pre>
  <p>Now the error encountered is:</p>
  <blockquote>
  <p><strong>Invalid Query. You cannot use 'array_contains' filters with 'not_in' filters</strong></p>
  </blockquote>
  <p>How can I get the newly created records as well ?</p>