ArcGIS API For JS - Search faster with the Search Widget

510
1
08-13-2020 06:31 AM
PaulMcCord
Occasional Contributor

I'm using the Search tool to allow users to enter their address and be taken to their property of interest. This is for a parcel viewer application with over 800,000 records. Ideally, when the user enters their address in the Search, they will quickly be zoomed to their location of interest. However, right now it takes about 13 seconds for the Search to retrieve their address and zoom to the correct address. It's worth noting that all of the functionality is working (ie, the map eventually zooms to the location that was entered), it's just very slow.

The parcel layer that is being searched is the same parcel layer that is displayed on the map (called parcelLyr in the below code). Below is the code for the search tool:

//Create search tool to search addresses
    const searchTool = new Search({
        view: myView,
        sources: [
            {
                layer: parcelLyr
                searchFields: ["propstreet", "fullAdd2"],
                displayField: "fullAdd2",
                name: "LayerSearchSource",
                placeholder: "example: 500 Griswold",
                exactMatch: false,
                suggestionsEnabled: true,
                autoNavigate: false,
                resultGraphicEnabled: false,
                outFields: ["*"]
                
            }
            
        ],
        container: addressSearchBar,
        includeDefaultSources: false,
        resultGraphicEnabled: false,
        popupEnabled: false,
        locationEnabled: false,
        searchAllEnabled: false
    })

Is there something I can do to ensure that the correct address is retrieved more quickly?

Thanks,

Paul

0 Kudos
1 Reply
ReneRubalcava
Frequent Contributor

You can create an attribute index on those two fields and republish the service. Assuming you published it from desktop.