Search

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:

  1. The portal to search. The default is https://www.arcgis.com/sharing/rest/search for ArcGIS Online.
  2. Any fields and text, for example, "Streets", or "Elevation level".
  3. The type of item, for example, Web Map or Feature Service.
  4. 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.

ItemsGroups
titletitle
tagstags
descriptiondescription
snippetsnippet
tagKeywordsowner

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 query
const 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.

             
import { searchItems } from "@esri/arcgis-rest-portal";
// Define a query
const query = new arcgisRest.SearchQueryBuilder()
  .match("USA Demographics")
  .in("tags")
  .and()
  .match("esri")
  .in("owner");

arcgisRest.searchItems(query)
  .then((response) => {
    console.log(response);
});

Search by type

Find items by searching for a type of item.

             
import { searchItems } from "@esri/arcgis-rest-portal";
// Define a query
const query = new arcgisRest.SearchQueryBuilder()
  .match("London Map")
  .in("title")
  .and()
  .match("Web Map")
  .in("type");

arcgisRest.searchItems(query)
  .then((response) => {
    console.log(response);
});

Search for a group

Find groups by searching for a text in the title.

          
import { searchItems } from "@esri/arcgis-rest-portal";
// Define a query
const query = new arcgisRest.SearchQueryBuilder()
    .match("Hikers")
    .in("title")

arcgisRest.searchGroups(query)
.then((response) => {
  console.log(response);
});

Search near a location

Find items near point or an bounding box (extent).

                
import { searchItems } from "@esri/arcgis-rest-portal";
// Define a query
const query = new arcgisRest.SearchQueryBuilder()
  .match("Food carts")
  .and()
  .match("Web Map")
  .in("type")

  const params = {
    bbox: "-122.6750,45.5051" // Portland, Oregon
  }

  arcgisRest.searchItems(query, params)
  .then((response) => {
      console.log(response);
});