Select to view content in your preferred language

Search only with the layer features that are configured as searchable in ArcGIS Enterprise

227
6
Jump to solution
08-08-2024 07:08 AM
mmoosbac94
New Contributor

Hello everybody,

is it possible in ArcGIS Swift SDK to search only in the layer feature attributes that are configured as searchable in ArcGIS Enterprise (image below) and ignore the other attributes in a featureTable? We know its working with the searchbar in MapViewer in ArcGIS Enterprise and we would like to adapt the same functionality in iOS App.

When we are using "queryFeatures" function with "QueryParameters" the results of all layer feature attributes which match a specific input are returned regardless of weather configured searchable or not.

Are there any functions / parameters we should know about that?

Thank you very much.
Marvin 

Bildschirmfoto 2024-08-08 um 15.55.03.png

0 Kudos
1 Solution

Accepted Solutions
Ting
by Esri Contributor
Esri Contributor

That is a viable approach too. toJSON() gives you a JSON string, so you may use JSONDecoder() to parse the string into a custom Decodable struct that contains the fields you need from the JSON. The other consideration is that toJSON() is actually serializing the current map object, not the original object from the server. However, since the search settings don't get modified on the client side, it should not matter.

_unsupportedJSON should be functionally equivalent. The difference is that a) it is a dictionary, and b) it may be (unlikely) changed in the future.

View solution in original post

0 Kudos
6 Replies
Ting
by Esri Contributor
Esri Contributor

the results of all layer feature attributes which match a specific input are returned regardless of weather configured searchable or not.

Hi Marvin, can you elaborate on what this means, or can you show how do you configure the query parameters currently?

 

From the screenshot, I'm assuming that you intend to do something like this, but not totally sure.

 

let parameters = QueryParameters()
// … some configurations to the parameters?
parameters.whereClause = "NAME LIKE '%SEARCH_TERM%'"
policeStationsTable.queryFeatures(
    using: parameters,
    queryFeatureFields: .loadAll
)

 

I haven't used the enterprise "Enable search > By layer" feature, but I would imagine that it resembles constructing SQL queries using drop down menus.

So if you only want to search specific fields with certain criteria, you may write some SQL clauses using help from this documentation.

---

Edit 1: if possible, can you share the feature service that has the search settings configured via DM? We have experimentally supported the "_unsupportedJSON" property on the services, and it contains information for search settings. Info from this JSON can help to configure the query parameters.

0 Kudos
mmoosbac94
New Contributor

Hi Ting,

thank you for the quick reply!

Our goal is to configure the searchable featureLayers and attributes in ArcGIS Enterprise in Application Settings and use it in our iOS App. So layerFeature attributes in a table which are not configured "searchable" should not be searched. Currently we do something similar as you showed in your last post but it did not work because Application Settings search-configuration is not related to the queries directly.

Based on your information I think this functionality is not directly supported through the ArcGIS Swift SDK right? As you proposed, I tried to get the applicationSettings(search) information from the "unsupportedJson" property. But there is a warning that you should not use it in public and it will be removed in the future.

Instead I tried to use toJson() on the specific map-object to get the applicationSettings. And in this json I can see the layers which are configured as searchable with their layerAttributes and type of search. Do you think that its a valid approach to use this json to build up our SQL clauses?

0 Kudos
Ting
by Esri Contributor
Esri Contributor

The _unsupportedJSON property is experimental. There is a chance that it will be changed or removed in the future, but currently we have several products that rely on it, so it is likely that we'll keep it towards the end of this major release, until we have a better replacement.

0 Kudos
mmoosbac94
New Contributor

Hi Ting. Sorry for the delayed reply. 

But what about the map.toJSON() method? Within that json it seems that I can see the search settings, so which layer-features are marked searchable in the portal. Would that be a valid option so that I can check this json and create the SQL clauses accordingly?

0 Kudos
Ting
by Esri Contributor
Esri Contributor

That is a viable approach too. toJSON() gives you a JSON string, so you may use JSONDecoder() to parse the string into a custom Decodable struct that contains the fields you need from the JSON. The other consideration is that toJSON() is actually serializing the current map object, not the original object from the server. However, since the search settings don't get modified on the client side, it should not matter.

_unsupportedJSON should be functionally equivalent. The difference is that a) it is a dictionary, and b) it may be (unlikely) changed in the future.

0 Kudos
mmoosbac94
New Contributor

Thank you very much for the great support! That way its working now.

0 Kudos