As an admin for ArcGIS Online, I want to iterate through all of my hosted feature services so that I can check a few things.
- Organisation has over 10,000 items
- Having issues between the count of records returned from what appears to be the same query with search and advanced_search
from arcgis.gis import GIS
# connect to the portal
gis = GIS(profile='my_prof', expiration=9999) #PROD
# Create two lists to store results in
adv_S_list = []
search_list = []
# Count with standard search, maxes out at 10000
search_items = gis.content.search(query="*", item_type="Feature Service", max_items = 10000)
for i in search_items:
search_list.append((i.title, i.type))
# Count from regular search
print("#FS Items found using search: " + str(len(search_items))) #returns 3993, this seems correct from looking at items in search_list
# get a count using advanced_search
count_items = gis.content.advanced_search(
query = "orgid:vHnIGBHHqDR6y0CR and type:'Feature Service'",
max_items = 70000,
return_count = True
)
# Count from advanced_search
print("#FS Items found using advanced_search: " + str(count_items)) # returns 481
# paginate through using advanced_search and get a count
start = 0
len_sr = 100
while len_sr == 100:
all_items = gis.content.advanced_search(
query = "orgid:vHnIGBHHqDR6y0CR and type:'Feature Service'",
start = start,
max_items = 100
)
list_items = all_items.get('results')
len_sr = len(list_items)
start = start + 100
for i in list_items:
adv_S_list.append((i.title, i.type))
# Count from advanced_search pagination approach:
print("#FS Items found using advanced_search + pagination: " + str(len(adv_S_list))) # returns 482

What is the right approach to correctly loop through all the reocds from a feature service?