amcat4apiclient/amcat4apiclient.py
def query(self, index: str, q: Optional[str]= None, *,
              fields=('date', 'title', 'url'), scroll='2m', per_page=100, **params) -> Iterable[dict]:
        """
        Perform a query on this server, scrolling over the results to get all hits

        :param index: The name of the index
        :param q: An optional query
        :param fields: A list of fields to retrieve (use None for all fields, '_id' for id only)
        :param scroll: type to keep scroll cursor alive
        :param per_page: Number of results per page
        :param params: Any other parameters passed as query arguments
        :return: an iterator over the found documents with the requested (or all) fields
        """
        url = f"{self.host}/index/{index}/query"
        params['scroll'] = scroll
        params['per_page'] = per_page
        if fields:
            params['fields'] = ",".join(fields)
        if q:
            params['q'] = q
        while True:

            print(url)

            r = requests.get(url, auth=(self.username, self.password), params=params)
            if r.status_code == 404:
                break
            r.raise_for_status()
            d = r.json()
            yield from d['results']
            params['scroll_id'] = d['meta']['scroll_id']

        Perform a query on this server, scrolling over the results to get all hits

        :param index: The name of the index
        :param q: An optional query
        :param fields: A list of fields to retrieve (use None for all fields, '_id' for id only)
        :param scroll: type to keep scroll cursor alive
        :param per_page: Number of results per page
        :param params: Any other parameters passed as query arguments
        :return: an iterator over the found documents with the requested (or all) fields
        
Perform a query on this server, scrolling over the results to get all hits
Perform a query on this server scrolling over the results to get all hits
def query(self, index: str, q: Optional[str]= None, *,
              fields=('date', 'title', 'url'), scroll='2m', per_page=100, **params) -> Iterable[dict]:
        url = f"{self.host}/index/{index}/query"
        params['scroll'] = scroll
        params['per_page'] = per_page
        if fields:
            params['fields'] = ",".join(fields)
        if q:
            params['q'] = q
        while True:
            print(url)
            r = requests.get(url, auth=(self.username, self.password), params=params)
            if r.status_code == 404:
                break
            r.raise_for_status()
            d = r.json()
            yield from d['results']
            params['scroll_id'] = d['meta']['scroll_id']
def query ( self , index : str , q : Optional [ str ] = None , * , fields = ( 'date' , 'title' , 'url' ) , scroll = '2m' , per_page = 100 , ** params ) -> Iterable [ dict ] : url = f"{self.host}/index/{index}/query" params [ 'scroll' ] = scroll params [ 'per_page' ] = per_page if fields : params [ 'fields' ] = "," . join ( fields ) if q : params [ 'q' ] = q while True : print ( url ) r = requests . get ( url , auth = ( self . username , self . password ) , params = params ) if r . status_code == 404 : break r . raise_for_status ( ) d = r . json ( ) yield from d [ 'results' ] params [ 'scroll_id' ] = d [ 'meta' ] [ 'scroll_id' ]
Perform a query on this server, scrolling over the results to get all hits
Perform a query on this server scrolling over the results to get all hits
"""
        Perform a query on this server, scrolling over the results to get all hits

        :param index: The name of the index
        :param q: An optional query
        :param fields: A list of fields to retrieve (use None for all fields, '_id' for id only)
        :param scroll: type to keep scroll cursor alive
        :param per_page: Number of results per page
        :param params: Any other parameters passed as query arguments
        :return: an iterator over the found documents with the requested (or all) fields
        """
an iterator over the found documents with the requested (or all) fields
an iterator over the found documents with the requested ( or all ) fields
self
index
str
The name of the index
The name of the index
q
Optional[str]
An optional query
An optional query
fields
A list of fields to retrieve (use None for all fields, '_id' for id only)
A list of fields to retrieve ( use None for all fields ' _id ' for id only )
scroll
type to keep scroll cursor alive
type to keep scroll cursor alive
per_page
Number of results per page
Number of results per page
params
Any other parameters passed as query arguments
Any other parameters passed as query arguments