You can use the portal service to search for content in groups. This operation searches for items within a specific group. This search is performed on categories in a group. The search index is regularly updated when content is added or modified. The results of this type of search only include items accessible to the user based on permissions.
You can use content search to:
- Keywords such as titles, description, or tags.
- Filter content by predefined categories.
- Retrieve content based on geographic search or spatial extent.
Search parameters
To search for items, you make an HTTPS request to the portal service and use the search
operation. The search
operation supports a query string with fields, and operators, such as AND, OR, and NOT. You can perform an open search for text using the default fields or you can search for text in specific fields such as the title
, description
, or tags
. You can also specify a location to search near, or a bounding box to search in by defining the bbox
parameter.
The general steps to search for items are:
- Define the URL to the portal service:
https
.://org.arcgis.com/sharing/rest/content/groups/[group I D]/search - Provide the text for your search. For example, "Streets", or "Elevation level".
- Define the item type for your search. For example,
Web Map
orFeature Service
. - Set the sort order for your return results.
- Any additional fields, such as tags, date created, or last modified.
URL request
https://org.arcgis.com/sharing/rest/content/groups/[groupID]/search?<parameters>
Default fields
When searching for text in items or groups, if you do not provide fields, the following default fields are searched.
Items | Groups |
---|---|
title | title |
tags | tags |
description | description |
snippet | snippet |
tagKeywords | owner |
Key parameters
Name | Description | Examples |
---|---|---|
q | The text or formatted query with text. | q="streets" q="john+smith" q=(firstName:"john" OR lastName:"smith") |
filter | Apply structured filtering using field name. | filter=first filter=last |
sort | The primary sort field. | sortField=username sortField=created sortField=modified sortField=fullname |
sort | Return results in ascending or descending order. | sortOrder=asc sortOrder=desc |
categories | Search groups items using categories keywords. | categories=/ categories=/ |
category | Search groups items using category filters. | category |
bbox | Bounding box to perform spatial search | bbox=-118,32,-116,34 |
Query structure
Here are a some of the general rules for formatting queries:
- For an open search, specify the text at the beginning. e.g.
q="redlands+map"
- To search specific fields, use a colon
:
after the field name. e.g.filter=tags
:"transportation" - Use double quotes
"text"
around all user search text. - Capitalize all
AND
,OR
, andNOT
operators. - Use
()
to group operators.
For example:
https://org.arcgis.com/sharing/rest/content/groups/[groupID]/search?f=json&q="redlands+map"
Code examples
Search for maps in a group by keyword
Find maps with the keywords title and description.
# Enter the ID of the group you want to search in
group_id = "enter_group_id_here"
# Enter the keyword you want to search for
keyword = "enter_keyword_here"
# Get the group
group = gis.groups.get(group_id)
# Search for maps within the group by keyword
results = group.content.search(query=f'type:"Web Map" AND {keyword}')
Search for layers in a group by owner
Find layers in owner by a specific member in a group.
group_id = "enter_group_id_here"
owner = "enter_owner_username_here"
# Get the group
group = gis.groups.get(group_id)
# Initialize list to store layer items
layers = []
# Iterate through group content and filter layers by owner
for item in group.content():
if item.owner == owner and item.type == 'Feature Service':
layers.append(item)
Search for apps in a group by tags
Find apps in a group based on specific tags.
group_id = "enter_group_id_here"
# Enter the tags to search for
tags_to_search = "enter_tags_here"
# Get the group
group = gis.groups.get(group_id)
# Search for items within the group with the specified tags
results = group.content.search(query=f'type: "Web Mapping Application" AND tags: "{tags}"')
Search for content in a group by date
Find any type of item in a group based on specific date.
group_id = "your_group_id"
# Enter the start and end dates for the search
start_date = "YYYY-MM-DD"
end_date = "YYYY-MM-DD"
# Convert start_date and end_date to ArcGIS date format
start_date_arcgis = datetime.strptime(start_date, "%Y-%m-%d").date()
end_date_arcgis = datetime.strptime(end_date, "%Y-%m-%d").date()
# Perform search for content within the group based on date range
results = gis.content.search(query=f'group:{group_id} AND created:[{start_date_arcgis} TO {end_date_arcgis}]',
max_items=10) # Adjust max_items as needed
Tools
Use tools to access the portal and create and manage content for applications.
ArcGIS Enterprise
Create, manage, analyze, and share data, maps, and applications in your organization.
Portal
Create, manage, and access content and data services for applications.
Map Viewer
Create, explore, and share web maps for 2D applications.
Scene Viewer
Create, style, and explore web scenes.
Vector Tile Style Editor
Create styles for basemap and vector tile layers.
Content management tools
Create, manage, organize, and share items in a portal.
Data management tools
Import data and create hosted layers and data services. Upload and manage documents, images, and other files.
Spatial analysis tools
Perform feature and raster analysis to create new datasets with the Map Viewer.
Developer credentials tool
Create API key and OAuth 2.0 developer credentials for custom applications.
Items
Manage and share items.
ArcGIS Pro
Create, style, and explore maps and scenes.
Geoprocessing tools
Import, manage, and analyze data.