title: Are complex compound queries possible in Firebase Firestore?
body: <p>I am using Firebase as a backend for an app, and I need to create a matchmaking system where users are matched to the current user using a number of criteria.</p>
  <p>Since the database can contain a huge amount of users, I would like to avoid retrieving every single user from the database and filtering it manually, to avoid loading times.</p>
  <p>The relevant data stored in each user document includes: <code>date of birth</code> (Timestamp), <code>an array of user interests</code> (list of strings), <code>an array of already matched user ids</code> (list of strings), and the <code>user's gender preference</code> (string F or M).</p>
  <p>It should find user data according to the following queries:</p>
  <ol>
  <li>Date of birth must be at most 2 years lower or higher than the current user</li>
  <li>The interests array must contain at least one common interest with the current user</li>
  <li>The gender must match the current user's gender preference</li>
  <li>The user id must not already be in the current user's already matched user ids list</li>
  </ol>
  <p>After the list of matching users is retrieved, I would also like it to be sorted by the amount of common interests with the current user, so the best match shows first.</p>
  <p>So far the only solution I have is to get 50 random users from the database, check if they match (in code), and if less than 6 matches are found, keep repeating until at least 6 matches are found.
  In case no matching users are found in the entire database, then simply get 6 random users.</p>
  <p>I am aware of the limitations that Firebase has when it comes to querying and filtering data, so I'm asking if something like this is even possible?</p>