AnsweredAssumed Answered

Use REST API to check for duplicates?

Question asked by geonetadmin on Mar 19, 2013
Original User: oppedahl

Is there a way through the REST API to determine if an field in a feature class contains any duplicate values? We used to use ArcObjects' DataStatistics.GetUniqueValueCount on the field in question and compare it to the FC's row count. If the unique value count was less, there were duplicates. With REST the only way appears to be to sort the FC by the field in question and read through all the values, comparing the current field to the previous. But if there are no dups, you end up reading through the entire FC, which takes many minutes if there are tens of thousands of features. The old way took milliseconds.

We tried groupByFieldsForStatistics, grouping on the field in question and querying for count. If any count > 1, there are dups. But you have to read through all the counts (tens of thousands again if no dups); there's no way to simply return true or false that count > 1 exists.

We tried returnDistinctValues thinking we could use it in conjunction with returnCountOnly, and compare the distinct count with the full record count. But returnCountOnly doesn't work with returnDistinctValues, so again, you're forced to read through all the records.