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