Query resultRecordCount ignores returnDistinctValues

1004
4
09-27-2018 04:53 PM
BlakeTerhune
MVP Regular Contributor

My goal is to query the resultRecordCount with returnDistinctValues = true with one output field. Reason is because the result is sometimes more than 1000 and I need to paginate the queries and I can't do that without knowing the total number of distinct results.

However, it seems that resultRecordCount is ignoring the returnDistinctValues parameter and counting everything. Is there another way I can count distinct records? Maybe with some trickery using outStatistics or groupByFieldsForStatistics? I'm on ArcGIS Enterprise 10.5.1 calling REST MapServer through ArcGIS API for JavaScript 4.7.

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Blake,

   If you use executeForCount, then the returnDistinctValues will work to let you know if the map services MaxRecordCount is high enough to work with one query.

https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html#executeForCo... 

BlakeTerhune
MVP Regular Contributor

I think this is actually a bug. Here's a distinct query on a 10.5.1 service that returns 881 records with count but 534 without count. A similar query on a 10.6.1 service returns the same number of distinct records with and without count. Doesn't seem to matter if I do executeForCount or resultRecordCount.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Hmm. could be you should make a call to tech support on that.

BlakeTerhune
MVP Regular Contributor

Esri Support was able to replicate the issue and created

BUG-000117336 : The "returnDistinctValues" parameter is ignored when querying a ArcGIS Server 10.6 service with "resultRecordCount" / "Return Count only" parameter.

The development team will be reviewing the bug and will provide us further updates. The issue is not reproducible in the latest release of ArcGIS Server 10.6.1 and can be used as a workaround.

0 Kudos