<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Hitting Max Query Count when specifying IDS_ONLY in Java Maps SDK Questions</title>
    <link>https://community.esri.com/t5/java-maps-sdk-questions/hitting-max-query-count-when-specifying-ids-only/m-p/1262490#M2675</link>
    <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;I am hitting the max query count for a server when trying to query from the layer. As the API&amp;nbsp;&lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/query-feature-service-layer-.htm" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt; points out--&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"While there is a limit to the number of features included in the feature set response, t&lt;U&gt;here is no limit to the number of object IDs returned in the ID array response.&lt;/U&gt; Clients can exploit this to get all the query conforming object IDs by specifying&amp;nbsp;&lt;SPAN class=""&gt;returnIdsOnly=true&lt;/SPAN&gt;&amp;nbsp;and subsequently requesting feature sets for subsets of object IDs."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thus, I should request returnIDs only, and expect to get the total list of features with their corresponding ID's, however, when I do, I still get the max count number of features.&amp;nbsp; Below is the snippet of relevant code I use to query. I specify "IDS_ONLY" in line 55 with&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;featureTableToQuery.queryFeatureAsync(queryParameterHere, QueryFeatureFields.IDS_ONLY)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get up to 2000 features returned (which corresponds to the max count of the server), but I cannot figure out how to get the full list of Ids. Is there anything I am missing? Is this a bug? Any help would be appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: In this case I am querying based on the queryExtent. The whereClause = "", which should send back all features inside of the queryExtent with no SQL filter applied.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;/**
	 * Queries features from a feature layer.
	 * 
	 * @param featureLayerId  - the feature layer from which to query
	 * @param map             - the map to add to
	 * @param whereExpression - an SQL where string
	 * @param queryExtent     - the feature queried must conform to these geometry
	 *                        bounds
	 * @param returnGeometry  - return geometries with query
	 * @param returnIdsOnly   - return ids only
	 * @return list of loaded features or features with ids only
	 */
	public static List&amp;lt;Feature&amp;gt; queryFeaturesFromLayer(String featureLayerId, ArcGISMap map, String whereExpression,
			Geometry queryExtent, boolean returnGeometry, boolean returnIdsOnly) {

		try {

			FeatureLayer featureLayerToQuery = null;
			List&amp;lt;Feature&amp;gt; featureList = new ArrayList&amp;lt;&amp;gt;();

			// get the layer based on its Id
			for (Layer layer : map.getOperationalLayers()) {
				if (layer.getId().equals(featureLayerId)) {
					featureLayerToQuery = (FeatureLayer) layer;
					break;
				}
			}

			// check if feature layer retrieved based on layer Id
			if (featureLayerToQuery == null) {
				String msg = "Specified Id did not match any feature layer in this map";
				System.out.println(msg);
				return featureList;
			}

			// get the feature table from the feature layer: should always be the case right
			// now
			ServiceFeatureTable featureTableToQuery = (ServiceFeatureTable) featureLayerToQuery.getFeatureTable();

			// create a query for the state that was entered
			QueryParameters query = new QueryParameters();
			if (whereExpression != null &amp;amp;&amp;amp; !whereExpression.equals(""))
				query.setWhereClause(whereExpression);
			query.setReturnGeometry(returnGeometry);
			query.setMaxFeatures(0); // no max

			if (queryExtent != null) {
				query.setSpatialRelationship(SpatialRelationship.INTERSECTS);
				query.setGeometry(queryExtent);
			}

			// call query features
			ListenableFuture&amp;lt;FeatureQueryResult&amp;gt; future;
			if (returnIdsOnly) {
				future = featureTableToQuery.queryFeaturesAsync(query, QueryFeatureFields.IDS_ONLY);
			} else {
				future = featureTableToQuery.queryFeaturesAsync(query, QueryFeatureFields.LOAD_ALL);
			}
//			featureTableToQuery.
			try {
				// check if there are some results
				FeatureQueryResult featureQueryResult = future.get(); // block until ready!!

				if (featureQueryResult.iterator().hasNext()) {
					for (Feature feature : featureQueryResult) {
						featureList.add(feature);
					}
				} else {
					System.out.println("No features found for " + whereExpression);
					return featureList; // return empty list
				}
			} catch (Exception e) {

				e.printStackTrace();
			}
			return featureList;

		} catch (Exception e) {
			// on any error, display the stack trace
			e.printStackTrace();
			return null;
		}

	}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Feb 2023 18:23:39 GMT</pubDate>
    <dc:creator>JaredFaulk</dc:creator>
    <dc:date>2023-02-28T18:23:39Z</dc:date>
    <item>
      <title>Hitting Max Query Count when specifying IDS_ONLY</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/hitting-max-query-count-when-specifying-ids-only/m-p/1262490#M2675</link>
      <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;I am hitting the max query count for a server when trying to query from the layer. As the API&amp;nbsp;&lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/query-feature-service-layer-.htm" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt; points out--&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"While there is a limit to the number of features included in the feature set response, t&lt;U&gt;here is no limit to the number of object IDs returned in the ID array response.&lt;/U&gt; Clients can exploit this to get all the query conforming object IDs by specifying&amp;nbsp;&lt;SPAN class=""&gt;returnIdsOnly=true&lt;/SPAN&gt;&amp;nbsp;and subsequently requesting feature sets for subsets of object IDs."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thus, I should request returnIDs only, and expect to get the total list of features with their corresponding ID's, however, when I do, I still get the max count number of features.&amp;nbsp; Below is the snippet of relevant code I use to query. I specify "IDS_ONLY" in line 55 with&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;featureTableToQuery.queryFeatureAsync(queryParameterHere, QueryFeatureFields.IDS_ONLY)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get up to 2000 features returned (which corresponds to the max count of the server), but I cannot figure out how to get the full list of Ids. Is there anything I am missing? Is this a bug? Any help would be appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: In this case I am querying based on the queryExtent. The whereClause = "", which should send back all features inside of the queryExtent with no SQL filter applied.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;/**
	 * Queries features from a feature layer.
	 * 
	 * @param featureLayerId  - the feature layer from which to query
	 * @param map             - the map to add to
	 * @param whereExpression - an SQL where string
	 * @param queryExtent     - the feature queried must conform to these geometry
	 *                        bounds
	 * @param returnGeometry  - return geometries with query
	 * @param returnIdsOnly   - return ids only
	 * @return list of loaded features or features with ids only
	 */
	public static List&amp;lt;Feature&amp;gt; queryFeaturesFromLayer(String featureLayerId, ArcGISMap map, String whereExpression,
			Geometry queryExtent, boolean returnGeometry, boolean returnIdsOnly) {

		try {

			FeatureLayer featureLayerToQuery = null;
			List&amp;lt;Feature&amp;gt; featureList = new ArrayList&amp;lt;&amp;gt;();

			// get the layer based on its Id
			for (Layer layer : map.getOperationalLayers()) {
				if (layer.getId().equals(featureLayerId)) {
					featureLayerToQuery = (FeatureLayer) layer;
					break;
				}
			}

			// check if feature layer retrieved based on layer Id
			if (featureLayerToQuery == null) {
				String msg = "Specified Id did not match any feature layer in this map";
				System.out.println(msg);
				return featureList;
			}

			// get the feature table from the feature layer: should always be the case right
			// now
			ServiceFeatureTable featureTableToQuery = (ServiceFeatureTable) featureLayerToQuery.getFeatureTable();

			// create a query for the state that was entered
			QueryParameters query = new QueryParameters();
			if (whereExpression != null &amp;amp;&amp;amp; !whereExpression.equals(""))
				query.setWhereClause(whereExpression);
			query.setReturnGeometry(returnGeometry);
			query.setMaxFeatures(0); // no max

			if (queryExtent != null) {
				query.setSpatialRelationship(SpatialRelationship.INTERSECTS);
				query.setGeometry(queryExtent);
			}

			// call query features
			ListenableFuture&amp;lt;FeatureQueryResult&amp;gt; future;
			if (returnIdsOnly) {
				future = featureTableToQuery.queryFeaturesAsync(query, QueryFeatureFields.IDS_ONLY);
			} else {
				future = featureTableToQuery.queryFeaturesAsync(query, QueryFeatureFields.LOAD_ALL);
			}
//			featureTableToQuery.
			try {
				// check if there are some results
				FeatureQueryResult featureQueryResult = future.get(); // block until ready!!

				if (featureQueryResult.iterator().hasNext()) {
					for (Feature feature : featureQueryResult) {
						featureList.add(feature);
					}
				} else {
					System.out.println("No features found for " + whereExpression);
					return featureList; // return empty list
				}
			} catch (Exception e) {

				e.printStackTrace();
			}
			return featureList;

		} catch (Exception e) {
			// on any error, display the stack trace
			e.printStackTrace();
			return null;
		}

	}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 18:23:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/hitting-max-query-count-when-specifying-ids-only/m-p/1262490#M2675</guid>
      <dc:creator>JaredFaulk</dc:creator>
      <dc:date>2023-02-28T18:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Hitting Max Query Count when specifying IDS_ONLY</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/hitting-max-query-count-when-specifying-ids-only/m-p/1278798#M2686</link>
      <description>&lt;P&gt;I opened this issue with support and ended up with a feature request for the SDK. A Simple workaround is to hit the REST API directly to get all ID's and then loop through to get all features using the SDK query function.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 15:01:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/hitting-max-query-count-when-specifying-ids-only/m-p/1278798#M2686</guid>
      <dc:creator>JaredFaulk</dc:creator>
      <dc:date>2023-04-14T15:01:53Z</dc:date>
    </item>
  </channel>
</rss>

