Search content in groups

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:

  1. Define the URL to the portal service: https://org.arcgis.com/sharing/rest/content/groups/[groupID]/search.
  2. Provide the text for your search. For example, "Streets", or "Elevation level".
  3. Define the item type for your search. For example, Web Map or Feature Service.
  4. Set the sort order for your return results.
  5. Any additional fields, such as tags, date created, or last modified.

URL request

Use dark colors for code blocksCopy
1
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.

ItemsGroups
titletitle
tagstags
descriptiondescription
snippetsnippet
tagKeywordsowner

Key parameters

NameDescriptionExamples
qThe text or formatted query with text.q="streets"
q="john+smith"
q=(firstName:"john" OR lastName:"smith")
filterApply structured filtering using field name.filter=firstName:"john"
filter=lastName:"john"
sortFieldThe primary sort field.sortField=username
sortField=created
sortField=modified
sortField=fullname
sortOrderReturn results in ascending or descending order.sortOrder=asc
sortOrder=desc
categoriesSearch groups items using categories keywords.categories=/Categories/Water,Categories/Forest
categories=/Region/United States
categoryFiltersSearch groups items using category filters.categoryFilter=basemap,ocean
bboxBounding box to perform spatial searchbbox=-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, and NOT operators.
  • Use () to group operators.

For example:

Use dark colors for code blocksCopy
1
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.

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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}')
Expand

Search for layers in a group by owner

Find layers in owner by a specific member in a group.

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)
Expand

Search for apps in a group by tags

Find apps in a group based on specific tags.

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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}"')
Expand

Search for content in a group by date

Find any type of item in a group based on specific date.

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
Expand

Tools

Use tools to access the portal and create and manage content for applications.

Services

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.