HOW TO
When using ArcGIS API for Python in various workflows such as Clone, Export, and so forth, it may be necessary to find specific items in ArcGIS Online or Portal for ArcGIS and perform the action on only those items. To do this, the search function in arcgis.gis module can be used. It is also possible to use different queries or a combination of queries to find and use certain items.
This article shows some examples to use queries to find items in ArcGIS Online or Portal for ArcGIS using ArcGIS API for Python.
Examples to use query in Search function to return specific items in ArcGIS Online
items = gis.content.search(query='')
items = gis.content.search(query='KEYWORD')
items = gis.content.search(query='owner:YOUR USERNAME') items = gis.content.search(query='NOT owner:YOUR USERNAME')
username = "YOUR USERNAME" items = gis.content.search(query='owner:'+username) items = gis.content.search(query='owner:{}'.format(username)
items = gis.content.search(query="owner:" + gis.users.me.username)
items = gis.content.search(query='title:TITLE')
Search for content that begin with a prefix:
items = gis.content.search(query='title:TITLE*')
items = gis.content.search(query='', item_type='Feature Service') items = gis.content.search(query='', item_type='Web Map') items = gis.content.search(query='', item_type='Web Mapping Application')
items = gis.content.search(query='', item_type='Map')
items = gis.content.search(query='title:TITLE', outside_org=True)
items = gis.content.search(query='title:TITLE, owner:YOUR USERNAME', item_type='Feature Layer') items = gis.content.search(query='title:TITLE, type:map, owner:YOUR USERNAME')
Get help from ArcGIS experts
Download the Esri Support App