title: Firestore - Merging two queries locally
body: <p>Since there is no logical <code>OR</code> operator in Firestore, I am trying to merge 2 separate queries locally. </p>
  
  <p>Now I wonder how I can keep up the proper order of the results. When I run 2 queries independently, I can't oder the results specificly (at least not the order in which I get the results from Firestore with the <code>orderBy</code> method).</p>
  
  <p>My idea was to put the 2nd query inside the <code>onSuccessListener</code> of the 1st query. Is this a bad idea performance wise?</p>
  
  <pre><code>public void loadNotes(View v) {
      collectionRef.whereLessThan("priority", 2)
              .orderBy("priority")
              .get()
              .addOnSuccessListener(new OnSuccessListener&lt;QuerySnapshot&gt;() {
                  @Override
                  public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
  
                      for (QueryDocumentSnapshot documentSnapshot : queryDocumentSnapshots) {
                          Note note = documentSnapshot.toObject(Note.class);
                          //adding the results to a List
                      }
  
                      collectionRef.whereGreaterThan("priority", 2)
                              .orderBy("priority")
                              .get()
                              .addOnSuccessListener(new OnSuccessListener&lt;QuerySnapshot&gt;() {
                                  @Override
                                  public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
  
                                      for (QueryDocumentSnapshot documentSnapshot : queryDocumentSnapshots) {
                                          Note note = documentSnapshot.toObject(Note.class);
                                          //adding the results to a List
                                      }
                                  }
                              });
                  }
              });
  }
  </code></pre>