Search Suggestion not correct

308
3
09-03-2019 09:42 PM
SurajJha1
New Contributor III

I am using ArcGIS API for javascript 4.12. I have added a search widget into mapview. But the search suggestion is not correct. For example if i am searching 'Search CT' it is showing suggestion as 'Search RD'.  'Search CT' is available in data. Please help if you have any idea.

 

Thanks.

0 Kudos
3 Replies
Egge-JanPollé1
MVP Regular Contributor

Hi Suraj Jha,

Can you please tell us a little bit more about the configuration of your Search widget? Are you searching a Feature Layer? Which fields?

You might have a look at this code sample for inspiration:

Search widget with multiple sources | ArcGIS API for JavaScript 4.12 

I hope you will manage to get it working after some additional research.

Cheers,

Egge-Jan

SurajJha1
New Contributor III

Thanks for reply. We are using map service with layer id as a new feature layer for search. The url is like this https://server.com:6443/arcgis/rest/services/folder1/folder2/MapServer/6 . We have already tried the sandbox sample suggested by you but there also we have the same issue. The code is like below.

var featureLayerDistricts = new FeatureLayer({
url:
"https://server.com:6443/arcgis/rest/services/folder1/folder2/MapServer/6 ",
popupTemplate: {
// autocasts as new PopupTemplate()
title: "My Search",
overwriteActions: true
}
});

Thanks.

0 Kudos
SurajJha1
New Contributor III

One thing I would like to mention first time i get incorrect suggestion, after that when i delete couple of characters and re-type those characters I get the correct suggestions if again i do the same same thing I get incorrect suggestions. For example

1)First I type "Search CT" in search box I get "Search RD" as suggestions(Incorrect suggestions). 

2) I remove CT from Search box and type those(CT) again I get "Search CT" as suggestions (Correct Suggestions)

3) If I repeat step 2 I again get incorrect suggestions "Search RD" (Incorrect suggestions). 

Means if I perform step 2,  on every alternate search I am getting the correct suggestions. Hope I have explained the problem in details. If required I will provide more info.  Thanks.

0 Kudos