Hi.
I'm using Runtime's Find Task in order to find all features in a map service layer containing a specified string.
According to documentation the default value of FindParameters.Contains parameter is true (i.e. search is performed for a partial and not exact match).
In practice, however, the search is always performed for an exact match - whether FindParameters.Contains is set to either true or false.
After "sniffing" the actual REST URL generated by the task, I think I found the problem.
When FindParameters.Contains is set to true - the generated REST URL doesn't have the "contains" URL parameter at all, because it assumes the default value of true.
Unfortunately, REST API (at least in ArcGIS Server version 10.2.2 that I'm currently using) for Map Service's Find method falsely assumes the default value of false, contrary to its own documentation.
Is this a bug in 10.2.2?
Is there any workaround for this issue, except generating my own REST "find" request and parsing the results (from JSON)?
Thanks,
Alexander.
Hi Alexander,
Did you get a chance to try this with different server versions or just 10.2.2? if not try it with another version if you have the chance.
I wasn't able to reproduce the problem using different server versions including 10.2.2 and as you said the find request doesn't have contains value if not set or set to true, because true is the default value even on 10.2.2.
If you can provide repro sample or more details that will be good.
Thanks,
Asser
Hi, Asser.
I've been able to reproduce this behavior both on ArcGIS Server 10.1 & 10.2.2.
For clarification: the underlying data source of the map service's layer is a FGDB, registered appropriately with ArcGIS Server (registeted under "Registered folders" under "Data store").
For example, I'm searching for the partial string "hel".
Here's what I'm getting in response to REST request with the "contains" parameter explicitly set to "true".
Request URL: http://[Map service REST URL]/MapServer/find?searchText=hel&contains=true&searchFields=&sr=&layers=2&layerDefs=&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&dynamicLayers=&returnZ=false&returnM=false&gdbVersion=&f=pjson
Response JSON:
{
"results": [
{
"layerId": 2,
"layerName": "Major lakes",
"displayFieldName": "name",
"foundFieldName": "name_abb",
"value": "L. Chelan",
"attributes": {
"OBJECTID": "1130",
"Shape": "Polygon",
"featurecla": "Reservoir",
"scalerank": "5",
"name": "Lake Chelan",
"name_abb": "L. Chelan",
"name_alt": " ",
"note": " ",
"delta": " ",
"dam_name": " ",
"year": "1927",
"admin": " ",
"DontShow": "0"
},
"geometryType": "esriGeometryPolygon",
"geometry": {
"rings": [
],
"spatialReference": {
"wkid": 102139,
"latestWkid": 3067
}
}
},
{
"layerId": 2,
"layerName": "Major lakes",
"displayFieldName": "name",
"foundFieldName": "name_abb",
"value": "Mitchell L.",
"attributes": {
"OBJECTID": "1188",
"Shape": "Polygon",
"featurecla": "Reservoir",
"scalerank": "9",
"name": "Mitchell Lake",
"name_abb": "Mitchell L.",
"name_alt": " ",
"note": " ",
"delta": " ",
"dam_name": " ",
"year": "-99",
"admin": " ",
"DontShow": "0"
},
"geometryType": "esriGeometryPolygon",
"geometry": {
"rings": [
],
"spatialReference": {
"wkid": 102139,
"latestWkid": 3067
}
}
}
]
}
From the above you can see, that with an explicit contains=true a partial "hel" string is correctly matched to full strings in underlying data: "L. Chelan", "Mitchell L."
According to documentation, the same URL with no contains parameter specified at all should produce the same results (since contains=true is assumed by default).
However, the following URL (same one as above, but with contains parameter omitted) returns no results whatsoever.
Request URL: http://[Map service REST URL]/MapServer/find?searchText=hel&searchFields=&sr=&layers=2&layerDefs=&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&dynamicLayers=&returnZ=false&returnM=false&gdbVersion=&f=pjson
Response JSON:
{
"results": [
]
}
So, I'm really lost here.
It seems, that when contains parameter is omitted from the REST's Find request URL => the value of false is actually assumed by default instead of true, and, consequently, only exact matches are performed.
Please, advise.
Alexander.
Hi Alexander,
Doesn't seem like it is a specific version server issue. Did you have a chance to reproduce this with any of the public services? I am still not able to reproduce it.
If you can send me a repro sample using a public service that will help a lot.
Thanks,
Asser
Hello, Asser.
I am able to reproduce this behavior using ArcGIS Online public map service "World_Topo_Map" (against the single service layer 0 - "Citations"):
I am searching for "Coun" string and expecting REST's Find operation to match all partial "Coun" strings like "County" etc.
Here are the results:
1. Explicitly specifying "contains=true":
Result: many results, each one with the partially matched "Coun" string in one of the fields.
2. Explicitly specifying "contains=false":
Result: no results, since no feature in the queried layer contains the exact string "Coun" in any of its fields.
3. Omitting "contains" parameter entirely:
Result: no results, same as in case 2 above.
Conclusion: omitting "contains" parameter implicitly applies the default value of "contains=false", contrary to REST's Find operation documentation, which clearly states:
contains | Description: If false , the operation searches for an exact match of the searchText string. An exact match is case sensitive. Otherwise, it searches for a value that contains the searchText provided. This search is not case sensitive. The default is true . |
Again - am I missing something?
Please, advise.
Alexander.
Hi Alexander,
Thanks for taking the time to provide this sample urls. I can see what you talking about now, and looks like it was an issue that fixed on 10.3.
On the .NET SDK we will consider adding the value to the url no matter what the default value is.
For now the best way to workaround it is to create your own REST url.
Thanks again,
Asser
Hi, Asser.
Do you mean - ArcGIS Server 10.3?
Hi Alexander,
Yes ArcGIS Server 10.3
Hi, Asser.
I've upgraded ArcGIS Server from 10.2.2 to 10.3, but, unfortunately, the problem still persists .
I'm still experiencing an "exact match" behavior (i.e. "contains=false") whenever the "contains" parameter is omitted from the respective REST URL.
I'm really lost here.
Please, let me know, whether there is any workaround for this: how can I use ArcGIS Runtime's "Find" task with a partial match? Maybe it's because my underlying service data is stored in FGDB?
Alexander.
Hi Alexander,
I am not sure if this is because of the service data type or not. But thanks for letting us know.
I created a quick workaround in the attachments, it is just a HttpClient request and the returned JSON
deserialized to another object matches the FindResult.Results object so you can use it the same way. Please note that this workaround is for Store apps you can create similar workaround for Desktop apps too.
Thanks,
Asser