You can search for items, users, and groups in a portal.
Searching a portal
To search for items, you can make an HTTPS request to a portal and use the search operation. The search operation supports a query string with fields, and operators such as AND, OR, and NOT. You can search for text in 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.
To create and execute a query, you typically define the following:
The portal to search. The default is https://www.arcgis.com/sharing/rest/search for ArcGIS Online.
Any fields and text, for example, "Streets", or "Elevation level".
The type of item, for example, Web Map or Feature Service.
Any additional fields, such as tags, date created, last modified, and so forth.
Query structure
Here are a some of the general rules for formatting queries:
Use a colon : after the field names.
Use double quotes "text" around all search text.
Capitalize all AND, OR, and NOT operators.
Use () to group operators.
Use the type: field to define the type of content to return. e.g. type: Web Map
For example:
https://www.arcgis.com/sharing/rest/search?f=json&q=title:"London Tube" AND type:"Web Map" AND tags:Transportation
Default fields
When searching for text in items or groups, if no fields are provided, the following default fields are searched.
Items
Groups
title
title
tags
tags
description
description
snippet
snippet
tagKeywords
owner
For example:
https://www.arcgis.com/sharing/rest/search?f=json&q="Seven Natural Wonders of the World"
Examples
The following examples use ArcGIS REST JS to search the ArcGIS Online portal. To access a different portal, specify the portal URL.
Search with text
Find any type of item with the keywords title or description.
import { searchItems } from"@esri/arcgis-rest-portal";
// Define a queryconst query = new arcgisRest.SearchQueryBuilder()
.match("Seven Natural Wonders of the World")
.in("title")
.or()
.match("Seven Natural Wonders of the World")
.in("description")
arcgisRest.searchItems(query)
.then((response) => {
console.log(response);
});
Search by tags and owner
Find items by searching for tags and an owner name.