title: Firebase Firestore compound query variations
body: <p>I have a dynamically constructed Firestore query, like so:</p>
  
  <pre><code>    let db = firebase.firestore().collection('vehData')
  
      if (this.filters.model.selected) {
        db = db.where('Model', '==', this.filters.model.selected)
      }
  
      if (this.filters.condition.selected) {
        db = db.where('TitleStatus', '==', this.filters.condition.selected)
      }
  
      if (this.filters.year.selected) {
        db = db.where('Year', '==', this.filters.year.selected)
      }
  
      if (this.filters.autopilot.selected) {
        db = db.where('Autopilot', '==', this.filters.autopilot.selected)
      }
  
      if (this.filters.battery.selected) {
        db = db.where('Battery', '==', this.filters.battery.selected)
      }
  
      if (this.filters.sortBy.selected) {
        db = db.orderBy(this.filters.sortBy.selected, this.filters.sortBy.ascOrDesc)
      }
  
      db.limit(200).get().then((querySnapshot) =&gt; { ... })
  </code></pre>
  
  <p><code>this.filters</code> is just a data model for a group of select inputs.</p>
  
  <p>The issue however, is that Firebase insists I have a composite index setup for every single variation of the above query, for example:
  <code>Model ASC TitleStatus ASC</code> OR <code>Model ASC TitleStatus ASC Year ASC</code> OR <code>Model ASC TitleStatus ASC Year ASC Autopilot ASC</code></p>
  
  <p>Making an index for every scenario / possible combination of filters would not be an option obviously, has anyone got any tips on how I may get around this limitation?</p>