Max number of results in a query

Whenever I do a query with NXQL I got the expected total size of the result set. If I try to retrieve the results, only the first 1000 are accessible. This behaviour is independent from the client I use (e.g. Python, Java).

I have done some research and it seems that this restriction comes from Elasticsearch.

My question: Is there a simple way to increase this limit? E.g. a configuration parameter in nuxeo.conf? Or at least a simple workaround to this restriction?

0 votes

2 answers

731 views

ANSWER



I think the issue is that Nuxeo pages the results if you want to or not and the max page size is 1000. You'll have to explicitly fetch subsequent pages to get more results. Basically, you retrieve the first results starting with currentPageIndex=0 and then increase currentPageIndex and retrieve again. Until you have all the results. That is when Nuxeo returns zero entries. That's what I am doing in Python.

def query_paged(self, query):
    index = 0
    while True:
        query_result = self.nx.documents.query({"query": query, "pageSize": 100, "currentPageIndex": index})
        page = query_result["entries"]
        if len(page) > 0:
            for entry in page:
                yield entry
        else:
            break
        index += 1

Nuxeo actually returns the number of results and pages (at least I think it does). So you could do it in a more sophisticated way.

1 votes



Konrad, many thanks. It works!

BTW: Very elegant yield construct, which was new to me. BTW(2): I wasn't aware that nx.documents.query exists; I only used nx.client.query as described in https://doc.nuxeo.com/nxdoc/python-client/

0 votes