code: def search(self, query, fields=None, page=1, max_records=None, flatten=True):
          
          if fields is None:
              fields = []
          page = int(page)
          pages = float('inf')
          data = {
              "query": query,
              "page": page,
              "fields": fields,
              "flatten": flatten
          }
  
          count = 0
          while page <= pages:
              payload = self._post(self.search_path, data=data)
              pages = payload['metadata']['pages']
              page += 1
              data["page"] = page
  
              for result in payload["results"]:
                  yield result
                  count += 1
                  if max_records and count >= max_records:
                      return
docs: returns iterator over all records that match the given query