vgrem / Office365-REST-Python-Client

Microsoft 365 & Microsoft Graph Library for Python
MIT License
1.36k stars 337 forks source link

Read large lists, using filter(), order_by() and top() #681

Open chelsy-mena opened 1 year ago

chelsy-mena commented 1 year ago

I am currently trying to read only the last week's entries of a few lists, and I accomplish this by using filter("Modified gt datetime{date_in_isoformat}') or order_by("Modified desc").top(50) along with get(); but now one of my lists has crossed the 5000 entries threshold and I get a 500 Error because of it, if I use paged(5000) or get_all(5000) it doesn't seem to work with filter() or order_by() and top().

Is this a limitation? Do I need to chain these in a specific order?

Thank you for any insight

InMDK commented 9 months ago

You can use the filter syntax on lists larger than the 5000 threshold if the column you are referencing is set to indexed in the list configuration. e.g. list_object.items.filter(filterText).get_all().execute_query()