How do I search all content in my portal using gis.content.search?

2474
3
Jump to solution
04-17-2018 12:38 PM
GajananBalasubramaniam1
New Contributor III

How can this be done? I want to be able to search all contents (layers, collection, service, maps, apps .,ect) found in my Portal. 

1 Solution

Accepted Solutions
SethLewis1
Occasional Contributor III
#import modules
from arcgis.gis import *
from IPython.display import display

#declare a connection to your portal
gis = GIS("portal URL", "user", "pass")
print("Successfully logged in as: " + gis.properties.user.username)

#search for items without passing in string values to the query or type parameters
items = gis.content.search('', '',)
for item in items:
  display(item)‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

3 Replies
SethLewis1
Occasional Contributor III
#import modules
from arcgis.gis import *
from IPython.display import display

#declare a connection to your portal
gis = GIS("portal URL", "user", "pass")
print("Successfully logged in as: " + gis.properties.user.username)

#search for items without passing in string values to the query or type parameters
items = gis.content.search('', '',)
for item in items:
  display(item)‍‍‍‍‍‍‍‍‍‍‍‍
GajananBalasubramaniam1
New Contributor III

Perfect! Thank You!!

DanHuber
New Contributor III

Seth's answer is correct, but the gis.content.search() method only returns the first 10 items found.   You need to add the parameter "max_items=" and set the value greater than the number of items you have in your Portal.