title: Is there a better way to optimise this Firestore Query?
body: <p>Right now I query Firestore arrays based on another array of strings. This works fine but I would like to know if this is correct and if there is a way to optimise it to make it faster.</p>
  
  <p>Here is my code.</p>
  
  <pre><code>var exampleArray = [test]()
  
  func loadData(textArray : [String]){
          let db = Firestore.firestore()
  
          for i in 0..&lt;textArray.count{
              db.collection("testCollection").whereField("testField", arrayContains: textArray[i]).getDocuments{ (querySnapshot, err) in
                  if let err = err {
                      print("\(err.localizedDescription)")
                      print("Test Error")
                  } else {
                      if (querySnapshot!.isEmpty == false){
                          let res = querySnapshot!.documents.compactMap({test(dictionary: $0.data())})
                          self.exampleArray.append(contentsOf: res)
                          self.summaryTableView.reloadData()
                          SVProgressHUD.dismiss()
                          print(self.textArray[i])
  
                      }
                  }
              }
          }
      }
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Some info:</p>
  
  <ul>
  <li>Right now the VisionCloudRecognition process and query take about 10-11sec. 7 sec the recognition and 3-4 the query.</li>
  <li>The Database has 7700 documents, 7 fields each.</li>
  </ul>
  
  <p>Basically my app does the following:</p>
  
  <ul>
  <li>User takes a photo</li>
  <li>With OCR the image becomes text and i append the text in an array of strings.We don't know how many strings are going to be. Maybe 0 or maybe 50.</li>
  <li>Then i query Firestore arrays based on the array of strings.</li>
  </ul>