remove objectid from query

376
1
08-23-2022 04:36 AM
RiccardoKlinger
Occasional Contributor

Dear Community,

I am developing a search and the search should operate only on two columns aka "name" and "alternate". the search widget as coded:

const source: any[] = [];
    searchConfig.sources.forEach((sourceItem) => {
        source.push({
            layer: new FeatureLayer({
                url: sourceItem.url,
                outFields: ['*'],
            }),
            searchFields: ["name", "alternate"],
            displayField: "name",
            exactMatch: true,
            outFields: ["name", "alternate"],
            name: "source layer"
            placeholder: "whoop",
            suggestionTemplate: "Name: {name}",
            maxResults: 5,
            suggestionsEnabled: false,
        });
    });

    const searchWidget = new Search({
        view: stores.mapStore.mapView,
        allPlaceholder: 'quickSearch',
        sources: [],
        searchAllEnabled: true,
        locationEnabled: false,
        includeDefaultSources: false,
    });
    searchWidget.set('sources', source);
Unfortunately the GET call also searches for the objectid:
GET HTTP://URL_TO_FEATURESERVER/1/query?f=pbf&maxAllowableOffset=1&resultRecordCount=1&where=(name = 68) OR (alternate = '68') OR (objectid = 68)&outFields=name,alternate,objectid&outSR=102100&spatialRel=esriSpatialRelIntersects&token=MYCOOLTOKEN
I want to remove "objectid" from the fields to be searched. How can I do this?
0 Kudos
1 Reply
JoelBennett
MVP Regular Contributor

I think you can fix this by not setting the FeatureLayer's outFields to ["*"].  Instead, I believe you should limit the outFields to just the ones you want to search, .e.g ["name","alternate"].