Hide Table of Contents
View Search using a suggestion template sample in sandbox
Search using a suggestion template


This sample demonstrates how you can work with a suggestion template when using the Search widget. At 3.14, a constructor option was added to thesource. The suggestionTemplate option allows the search box to display a string template with multiple fields based on user's input. In this particular example, we are searching based on a parcel owner's name.The resulting suggestions display the parcel id and address for the specified owner name.

Suggestions are available if working with a 10.3 geocoding service that has suggest capability loaded or a 10.3 feature layer that supports pagination, i.e. supportsPagination = true. Also, if using the Esri locator, suggest does not have an option to return a number of suggestions. The following property allows you to verify that a feature layer supports pagination.

featureLayer.advancedQueryCapabilities.supportsPagination === true


<!DOCTYPE html>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
  <title>Search with Suggestion Template</title>
    <link rel="stylesheet" href="https://js.arcgis.com/3.46/dijit/themes/claro/claro.css">
    <link rel="stylesheet" href="https://js.arcgis.com/3.46/esri/css/esri.css">
    #map {
      height: 100%;
      width: 100%;
      margin: 0;
      padding: 0;

    #search {
      display: block;
      position: absolute;
      z-index: 2;
      top: 20px;
      left: 74px;
    <script src="https://js.arcgis.com/3.46/"></script>

        "esri/map", "esri/dijit/Search", "esri/layers/FeatureLayer",  "esri/InfoTemplate", "dojo/domReady!"
      ], function (Map, Search, FeatureLayer,InfoTemplate) {
      var map = new Map("map", {
        basemap: "gray-vector",
        center: [-82.93, 42.5], // lon, lat
        zoom: 9

      var search = new Search({
        sources: [{
          featureLayer: new FeatureLayer("https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_Senators_2020/FeatureServer/0", {
            outFields: ["*"],
            infoTemplate: new InfoTemplate("Senators", "Senator name: ${Name}</br>Party: ${Party}</br>Address: ${Address}")
          outFields: ["Name","Party","Address"],
          displayField: "Name",
          suggestionTemplate: "${Name}",
          name: "Senators",
          placeholder: "example: Brown",
          enableSuggestions: true
        map: map
      }, "search");


  <div id="search"></div>
  <div id="map"></div>

Show Modal