Remove objectid from query in Esri search widget

565
4
09-06-2022 06:04 AM
UzmaBaloch
New Contributor

I am developing a search and the search should operate only on two columns aka "name" and "alternate". The search Widget as Coded using ArcGIS JavaScript API 4.22:

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
4 Replies
ReneRubalcava
Frequent Contributor

I have tried a bunch of variations of of this and cannot replicate this behavior. If you provide a codepen or simplified github sample, could better help, but not sure otherwise.

0 Kudos
JoelBennett
MVP Regular Contributor

This is practically identical to this post.  Have you tried the solution proposed there?

0 Kudos
JoelBennett
MVP Regular Contributor

Sorry, wrong URL...I meant this one.

0 Kudos
Noah-Sager
Esri Regular Contributor

I think @JoelBennett's post in the other thread addresses this question.

0 Kudos