title: How to limit number of Firebase compound indexes for querying with multiple filters
body: <p>I am creating a Firestore project that contains group chats/forums where users can filter the posts based on these fields:</p>
  <ul>
  <li>Number of likes</li>
  <li>If the post contains attachments (photos and/or files)</li>
  <li>4 Tags (Questions, Exams, Assignments, Notes)</li>
  </ul>
  <p>Users can apply any or all of these filters at the same time.</p>
  <p>Each Post document has the following fields:</p>
  <ol>
  <li>Number of Clips</li>
  <li>A different boolean for each of the tags</li>
  <li>A list of the files in the post</li>
  <li>The text of the post</li>
  </ol>
  <p>My method for creating these queries looks like this:</p>
  <pre><code>  setQueryFilters() {
        var queryPosts = db.collection('posts').where('course_id', '==', this.course);
  
        if (this.filterByNotes) {
          queryPosts = queryPosts.where('notesTag', '==', true);
        }
  
        if (this.filterByExams) {
          queryPosts = queryPosts.where('examsTag', '==', true);
        }
  
        if (this.filterByAssignments) {
          queryPosts = queryPosts.where('assignmentsTag', '==', true);
        }
  
        if (this.filterByQuestions) {
          queryPosts = queryPosts.where('questionsTag', '==', true);
        }
  
        if (this.filterByFiles) {
          queryPosts = queryPosts.where('files', '!=', []);
        }
  
        if (this.filterByClips) {
          queryPosts = queryPosts.orderBy('clips', 'desc');
        } else {
          queryPosts = queryPosts.orderBy('created_at', 'desc');
        }
  
        return queryPosts;
      },
  </code></pre>
  <p>Since there are 6 different filters that can be applied, I have hundreds of potential different queries, and all of them (except a few) require me to create compound indexes in firebase. I'm not even sure if firebase will allow me to create this many indexes. Is there a better way to do this?</p>