Search Widget Dropdown Suggestions - Only Ones That "Start With" The Search Term

1384
4
03-05-2021 03:14 PM
Status: Implemented
DaveFullerton
Occasional Contributor III

I think a property should be added to set the Search Widget or Layer Search Source to limit the search using the like operator so that the query would be <searchField> like '<searchTerm>%'.  The prefix and suffix properties won't work for this.

I am using a feature layer search source with the Search Widget.  The feature layer contains address points that have addresses with apartment numbers.  There are some single digit address numbers, such as 8 Wyclow St.  When users enter 8 into the input box, the top 6 suggestions do not include 8 Wyclow St or even, for example, 8000 Main St.  Instead the top suggestions presented are addresses with the character '8' elsewhere in the address text.

Here the suggestions for '8':

DaveFullerton_0-1614985982968.png

 

Here are the suggestions for '8 ':

DaveFullerton_1-1614985982955.png

 

And for '8 W':

DaveFullerton_2-1614985982878.png

 

 

4 Comments
jcarlson

This is a great idea! Even for non-address data, the variety within a "name" field can leave the actual relevant suggestions buried by the top features.

Noah-Sager

You should be able to enable this behavior for layerSearhSource using the exactMatch property. This should apply the wildcard in the search to the end of the search string as opposed to the beginning and the end of the search string, which is the default behavior.

test-app

https://codepen.io/noash/pen/GRMwgqr?editors=1000

doc

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-LayerSearchSource....

 

DaveFullerton

Thanks @Noah-Sager .  It appears that this is the case starting with version 4.20.

BjornSvensson
Status changed to: Implemented