Search widget with multiple sources

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

This sample demonstrates how to use the search widget to search on multiple Feature Layer Sources based in given fields. The search widget provides a capability for searching features in FeatureLayers or geocoding locations with a Locator.

To use multiple sources with the search widget, you must set search widget's sources property.

// Setting sources property of the search widget to use two feature layer sources.
var searchWidget = new Search({
    view: view,
    sources: [{
      featureLayer: new FeatureLayer({
        url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CongressionalDistricts/FeatureServer/0",
      }),
      searchFields: ["DISTRICTID"],
      displayField: "DISTRICTID",
      exactMatch: false,
      outFields: ["DISTRICTID", "NAME", "PARTY"],
      name: "Congressional Districts",
      placeholder: "example: 3708",
    }, {
     featureLayer: new FeatureLayer({
        url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_Senators/FeatureServer/0",
    }),
      searchFields: ["Name", "Party"],
      suggestionTemplate: "{Name}, Party: {Party}",
      exactMatch: false,
      outFields: ["*"],
      name: "Senators",
    }]
});

Sample search results

TitleSample

There were no match results from your search criteria.