AnsweredAssumed Answered

Search widget suggests for only two out of three fields in feature service

Question asked by KatherineMichael on May 3, 2016
Latest reply on Jun 1, 2016 by fcbassongis

Hello,

I am very new to using java script, and am having an issue with the suggest feature of the search widget.  Internet searches have not been helpful, so hopefully someone here can point me in the right direction.

 

I currently have a search widget in my application that is set to use the same feature service three times, once for each of the three fields that I want to be searchable.  The feature service is 10.3 and the pagination is set to true.  Basically, I am trying to provide three different ways to search for a parcel of property; by parcel number, by site address, or by owner name.  When searching by parcel number or site address, the widget returns suggestions.  However, when searching by owner name no suggestions are returned.  All searches are being performed on the same feature service, so it doesn't make sense for the suggest feature to work on two fields but not the third.  I tried adding an index to the owner name field, but this did not resolve the problem.  All of the fields in the feature class that the service was created from are text, so no differences there.  Am I doing something wrong with the java script or is there something wrong with the data itself?

 

This is the code:

 

var parcels = new FeatureLayer("http://myServerHere/gis/rest/services/TestingServices/TestTaxParcel_FeatureService/FeatureServer/0", {

        mode: FeatureLayer.MODE_ONDEMAND,

        infoTemplate: parcelPopup,

        outFields: ['PARCELID', 'CLASSCD', 'CLASSDSCRP', 'SITEADDRESS', 'OWNERNME1', 'OWNERNME2', 'PSTLADDRESS', 'PSTLCITY', 'PSTLSTATE', 'PSTLZIP5', 'PSTLZIP4', 'RESFLRAREA', 'NBRSTRUCT', 'MOBILEHOME', 'COMMUNITY', 'PA_URL']

    });

    map.addLayer(parcels);

             

    var search = new Search({

        enableButtonMode: true,

        activeSourceIndex: 0,

        sources: [{

                featureLayer: parcels,

                searchFields: ["PARCELID"],

                displayField: "PARCELID",

                exactMatch: false,

                outFields: ['PARCELID', 'CLASSCD', 'CLASSDSCRP', 'SITEADDRESS', 'OWNERNME1', 'OWNERNME2', 'PSTLADDRESS', 'PSTLCITY', 'PSTLSTATE', 'PSTLZIP5', 'PSTLZIP4', 'RESFLRAREA', 'NBRSTRUCT', 'MOBILEHOME', 'COMMUNITY', 'PA_URL'],

                name: "Parcel Search",

                placeholder: "Enter a parcel number",

                enableSuggestions: true

        }, {  

                featureLayer: parcels,

                searchFields: ["SITEADDRESS"],

                displayField: "SITEADDRESS",

                exactMatch: false,

                outFields: ['PARCELID', 'CLASSCD', 'CLASSDSCRP', 'SITEADDRESS', 'OWNERNME1', 'OWNERNME2', 'PSTLADDRESS', 'PSTLCITY', 'PSTLSTATE', 'PSTLZIP5', 'PSTLZIP4', 'RESFLRAREA', 'NBRSTRUCT', 'MOBILEHOME', 'COMMUNITY', 'PA_URL'],

                name: "Address Search",

                placeholder: "Enter a 911 address",

                enableSuggestions: true

        }, {

                featureLayer: parcels,

                searchFields: ["OWNERNME1"],

                displayFields: "OWNERNME1",

                exactMatch: false,

                outFields: ['PARCELID', 'CLASSCD', 'CLASSDSCRP', 'SITEADDRESS', 'OWNERNME1', 'OWNERNME2', 'PSTLADDRESS', 'PSTLCITY', 'PSTLSTATE', 'PSTLZIP5', 'PSTLZIP4', 'RESFLRAREA', 'NBRSTRUCT', 'MOBILEHOME', 'COMMUNITY', 'PA_URL'],

                name: "Owner Search",

                placeholder: "Enter owner name",

                enableSuggestions: true

        }],

        map:map

    }, "search");

             

    search.startup();

 

Any advice is greatly appreciated!

Outcomes