title: Cloud Firestore: FAILED_PRECONDITION: The query requires an index
body: <p>I made a query in Cloud Firestore,</p>
  
  <pre><code>CollectionReference questionRef = db.collection("collectionName");
          Query query = questionRef.whereEqualTo("field1", "content1")
                  .whereEqualTo("field2",content2)
                  .orderBy("field3")
                  .limit(LIMIT);
          query.get().addOnCompleteListener(new OnCompleteListener&lt;QuerySnapshot&gt;()
          {
              @Override
              public void onComplete(@NonNull Task&lt;QuerySnapshot&gt; task)
              {
                  if (task.isSuccessful())
                  {
                      for (DocumentSnapshot document : task.getResult())
                      {
                          Log.d(TAG, document.getId() + " =&gt; " + document.getData());
                      }
                  }
                  else
                  {
                      Log.w(TAG, "Error getting documents.", task.getException());
                  }
              }
          });
  </code></pre>
  
  <p>and I received errors, but I had an index.</p>
  
  <blockquote>
    <p>Error getting documents.
        com.google.firebase.firestore.FirebaseFirestoreException: FAILED_PRECONDITION: The query requires an index. You can create it
    here:
    <a href="https://console.firebase.google.com/project/exam-package/database/firestore/indexes?create_index=EglxYmFua2xpc3QaCQoFdmFsaWQQAhoNCgl0aW1lc3RhbXAQAxoMCghfX25hbWVfXxAD" rel="noreferrer">https://console.firebase.google.com/project/exam-package/database/firestore/indexes?create_index=EglxYmFua2xpc3QaCQoFdmFsaWQQAhoNCgl0aW1lc3RhbXAQAxoMCghfX25hbWVfXxAD</a>
            at com.google.firebase.firestore.g.zzs.zza(SourceFile:100)
            at com.google.firebase.firestore.b.zzd.zza(SourceFile:122)
            at com.google.firebase.firestore.b.zzab.zza(SourceFile:333)
            at com.google.firebase.firestore.b.zzf.zza(SourceFile:236)
            at com.google.firebase.firestore.f.zzo.zza(SourceFile:6529)
            at com.google.firebase.firestore.f.zzv.zzb(SourceFile:2089)
            at com.google.firebase.firestore.f.zza$zzb.zza(SourceFile:73)
            at com.google.firebase.firestore.g.zzm$1.onMessage(SourceFile:77)
            at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:36)
            at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:36)
            at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:498)
            at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
            at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
            at com.google.firebase.firestore.g.zza$zza.run(SourceFile:190)
            at java.lang.Thread.run(Thread.java:764)
         Caused by: io.grpc.StatusException: FAILED_PRECONDITION: The query requires an index. You can create it here:
    <a href="https://console.firebase.google.com/project/exam-package/database/firestore/indexes?create_index=EglxYmFua2xpc3QaCQoFdmFsaWQQAhoNCgl0aW1lc3RhbXAQAxoMCghfX25hbWVfXxAD" rel="noreferrer">https://console.firebase.google.com/project/exam-package/database/firestore/indexes?create_index=EglxYmFua2xpc3QaCQoFdmFsaWQQAhoNCgl0aW1lc3RhbXAQAxoMCghfX25hbWVfXxAD</a>
            at io.grpc.Status.asException(Status.java:534)
            at com.google.firebase.firestore.g.zzs.zza(SourceFile:98)
            at com.google.firebase.firestore.b.zzd.zza(SourceFile:122) 
            at com.google.firebase.firestore.b.zzab.zza(SourceFile:333) 
            at com.google.firebase.firestore.b.zzf.zza(SourceFile:236) 
            at com.google.firebase.firestore.f.zzo.zza(SourceFile:6529) 
            at com.google.firebase.firestore.f.zzv.zzb(SourceFile:2089) 
            at com.google.firebase.firestore.f.zza$zzb.zza(SourceFile:73) 
            at com.google.firebase.firestore.g.zzm$1.onMessage(SourceFile:77) 
            at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:36) 
            at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:36) 
            at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:498) 
            at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) 
            at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) 
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457) 
            at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) 
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 
            at com.google.firebase.firestore.g.zza$zza.run(SourceFile:190) 
            at java.lang.Thread.run(Thread.java:764)</p>
  </blockquote>