Autocomplete Search from Feature Service - User Input

321
3
Jump to solution
03-13-2024 01:45 PM
MattMilligan_CFL
New Contributor

I want to write an expression which will perform an autocomplete search on the address data (which come from Feature Service), filtering the results based on whether the address contains the postcode specified by the user in the previous text field ${postcode}. 

I came up with this

autocomplete search('address_text?url=https://services-eu1.arcgis.com/9jMaVDXGmPzM1yh9/arcgis/rest/services/address/FeatureServer/0', 'contains', 'address', ${postcode})

but it's not working... what's interesting this is working:

autocomplete search('address_text?url=https://services-eu1.arcgis.com/9jMaVDXGmPzM1yh9/arcgis/rest/services/address/FeatureServer/0', 'contains', 'address', 'E17 8PW')

 Any ideas please? 

0 Kudos
1 Solution

Accepted Solutions
MarikaVertzonis
Esri Regular Contributor

Some things to try:

 - double check 'postcode' is indeed the name of the previous question (a little obvious I agree, but just maybe there is a space, or is it capitalized?)

 - change 'contains' to 'matches' (does it make a difference in either of your expressions?) 

Is your postcode question also a select question, or is it a text question?

I just tried the Dynamic Choice Lists Using Search Appearance sample in Connect, and experimented with changing the leading question to be just a text box, where you type the state name rather than picking it from a list, and that also worked as expected (see attached my cut down of that sample). So yes, what you show SHOULD work. It's just a matter of finding the typo.

View solution in original post

0 Kudos
3 Replies
MarikaVertzonis
Esri Regular Contributor

Some things to try:

 - double check 'postcode' is indeed the name of the previous question (a little obvious I agree, but just maybe there is a space, or is it capitalized?)

 - change 'contains' to 'matches' (does it make a difference in either of your expressions?) 

Is your postcode question also a select question, or is it a text question?

I just tried the Dynamic Choice Lists Using Search Appearance sample in Connect, and experimented with changing the leading question to be just a text box, where you type the state name rather than picking it from a list, and that also worked as expected (see attached my cut down of that sample). So yes, what you show SHOULD work. It's just a matter of finding the typo.

0 Kudos
MattMilligan_CFL
New Contributor

Amazing, thank you for a quick response! I noticed that the syntax I used was actually correct, but due to a large dataset it is taking a really long time to load the dropdown. I replaced "contains" with "matches" and the difference is minimal. The dataset includes over 4 millions of addresses. Any ideas what to do to improve the performance?

Thank you!

0 Kudos
MarikaVertzonis
Esri Regular Contributor

There's only so much wizardry you can do with large data sets! You either need a more powerful device (you don't mention anywhere here what you are running this on (Windows, iOS, Android, older lower spec phone, newer top of the range phone?), or break up the list that you're searching. Could you add another search before this one that narrows the list down to state or county, and then search for postcode?

0 Kudos