Select to view content in your preferred language

Is there a bug with the Search widget for 4.26?

551
2
Jump to solution
03-07-2023 02:58 PM
_____
by
Frequent Contributor

I keep just getting:

No results
There were no results found for "search term".
 
When there should be results. I'm upgrading apps to 4.26, and the Search widget just isn't working. I even tried a very simple example, and it's still not working.

 

'esri/widgets/Search'
Search

// SEARCH WIDGET
const sources = [];

sources.push({
    featureLayer: new FeatureLayer({
        url: 'OurServer/MapServer/2',
    }),
    name: 'Service Point',
    displayField: 'gs_name',
    outFields: ['*'],
    searchFields: ['gs_name'],
    placeholder: 'Search for customer information.',
    maxResults: 3
});

const searchWidget = new Search({
    view: view,
    sources: sources,
    includeDefaultSources: false,
});

view.ui.add(searchWidget, {
    position: 'top-left',
    index: 0,
});

 

Super simple, but it just doesn't work. I don't see any network requests either.

Any idea what could be wrong here?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
_____
by
Frequent Contributor

I found out what was wrong not too long after posting, but for some reason I couldn't find this post, so I thought it was deleted or something.

Anyway, the problem is that featureLayer has been changed to just layer now. Once I made that change, then it worked.

sources.push({
    layer: new FeatureLayer({
        url: 'OurServer/MapServer/2',
    }),
    name: 'Service Point',
    displayField: 'gs_name',
    outFields: ['*'],
    searchFields: ['gs_name'],
    placeholder: 'Search for customer information.',
    maxResults: 3
});

 

View solution in original post

2 Replies
JoelBennett
MVP Regular Contributor

There doesn't seem to be anything wrong with what you have as far as I can tell.  However, changes made to the Search widget in 4.25 have caused some folks to notice *apparently* missing results, so If you're upgrading from a version prior to 4.25, you might check out this thread.

0 Kudos
_____
by
Frequent Contributor

I found out what was wrong not too long after posting, but for some reason I couldn't find this post, so I thought it was deleted or something.

Anyway, the problem is that featureLayer has been changed to just layer now. Once I made that change, then it worked.

sources.push({
    layer: new FeatureLayer({
        url: 'OurServer/MapServer/2',
    }),
    name: 'Service Point',
    displayField: 'gs_name',
    outFields: ['*'],
    searchFields: ['gs_name'],
    placeholder: 'Search for customer information.',
    maxResults: 3
});