Query service parameters

The following table provides details about the query service parameters.

Parameter

Details

Where

A where clause for the query filter. Any legal SQL where clause operating on the fields is allowed.

Example: where=POP2000 > 350000

Text

A literal text search. If the layer has a display field associated with it, the server searches for this text in this field.

Example: text=Los

Object IDs

The object IDs to be queried in this layer or table.

Syntax: ojbectIds=<objectId1>, <objectId2>

Example: objectIds=37, 462

Time

The time instant or the time extant to query.

Time instant

Syntax: time=<timeInstant>

Example: time=1199145600000 (1 Jan 2008 00:00:00 GMT)

Time extant

Syntax: time=<startTime>, <endTime>

Example: time=1199145600000, 1230768000000 (1 Jan 2008 00:00:00 GMT to 1 Jan 2009 00:00:00 GMT)

A null value specified for start time or end time will represent infinity for start time or end time respectively.

Input Geometry

The geometry to be applied as the spatial filter. The structure of the geometry is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API. For envelopes and points, you can also specify the geometry with a simpler comma-separated syntax.

Syntax:

  • structures: geometryType=<geometryType>&geometry={geometry}

  • envelope simple: geometryType=esriGeometryEnvelope&geometry=<xmin>,<ymin>,<xmax>,<ymax>

  • point simple: geometryType=esriGeometryPoint&geometry=<x>,<y>

Examples:

  • geometryType=esriGeometryEnvelope&geometry={xmin: -104, ymin: 35.6, xmax: -94.32, ymax: 41}

  • geometryType=esriGeometryEnvelope&geometry=-104,35.6,-94.32,41

  • geometryType=esriGeometryPoint&geometry=-104,35.6

Geometry Type

The type of geometry specified by the geometry parameter. The geometry type can be an envelope, point, line, or polygon. The default geometry type is an envelope.

Values:

  • esriGeometryPoint

  • esriGeometryMultipoint

  • esriGeometryPolyline

  • esriGeometryPolygon

  • esriGeometryEnvelope

Input Spatial Reference

The spatial reference of the input geometry. This can be specified as either a well-known ID or as a spatial reference JSON object.

If the input spatial reference (inSR) is not specified, the geometry is assumed to be in the spatial reference of the map.

Spatial Relationship

The spatial relationship to be applied on the input geometry while performing the query. The supported spatial relationships include intersects, contains, envelope intersects, within, etc.

The default spatial relationship is intersects. (esriSpatialRelIntersects)

Values:

  • esriSpatialRelIntersects

  • esriSpatialRelContains

  • esriSpatialRelCrosses

  • esriSpatialRelEnvelopeIntersects

  • esriSpatialRelIndexIntersects

  • esriSpatialRelOverlaps

  • esriSpatialRelTouches

  • esriSpatialRelWithin

  • esriSpatialRelRelation

Relation

The spatial relate function that can be applied while performing the query operation. An example for this spatial relate function is "FFFTTT***"

For more information on this spatial relate function please refer to the documentation for the spatial relate function.

Out Fields

The list of fields to be included in the returned result set. This list is a comma delimited list of field names. If you specify the shape field in the list of return fields, it is ignored. To request geometry:

returnGeometry=true

You can also specify the wildcard (*) as the value of this parameter. In this case, the query results include all the field values.

Example: outFields=AREANAME,ST,POP2000

Wildcard example: outFields=*

Return Geometry

If true, the result set includes the geometry associated with each result. The default is true.

Values:

  • true

  • false

Return True Curves

 

Max Allowable Offset

This option can be used to specify the maxAllowableOffset to be used for generalizing geometries returned by the query operation.

The maxAllowableOffset is in the units of the outSR. If outSR is not specified then maxAllowableOffset is assumed to be in the unit of the spatial reference of the map.

Example: maxAllowableOffset=2

Geometry Precision

This option can be used to specify the number of decimal places in the response geometries returned by the query operation.

This applies to X and Y values only (not m or z values).

Example: geometryPrecision=3

Output Spatial Reference

The spatial reference of the returned geometry.

The spatial reference can be specified as either a well-known ID or as a spatial reference JSON object.

If outSR is not specified, the geometry is returned in the spatial reference of the map.

Return IDs Only

If true, the response only includes an array of object IDs. Otherwise, the response is a feature set. The default is false.

Note: While there is a limit on the number of features included in the feature set response, there is no limit on the number of object IDs returned in the ID array response. Clients can exploit this to get all the query conforming object IDs by specifying returnIdsOnly=true and subsequently requesting feature sets for subsets of object IDs.

Values:

  • false

  • true

Return Count Only

If true, the response only includes the count (number of features or records) that would be returned by a query. Otherwise, the response is a feature set. The default is false. This option supersedes the returnIdsOnly parameter.

Values:

  • false

  • true

Order By Fields

Orders the features or records in ascending (ASC) or descending (DESC) order by field name.

Note:

  • orderByFields is supported only on the layers or tables that have supportsAdvancedQueries=true

  • orderByFields defaults to ASC (ascending order) if <ORDER> is unspecified.

Syntax: orderByFields=field1 <ORDER>, field2 <ORDER>, field3 <ORDER>

Example: orderByFields=CITY ASC, LAST_NAME DESC, ADDRESS

Group By Fields

Groups the features or records by field name to calculate statistics.

Note: grouByFieldsForStatistics is valid only when the outStatistics parameter is used.

Syntax: groupByFieldsForStatistics=field1, field2

Example: groupByFieldsForStatistics=CITY, LAST_NAME

Output Statistics

The definitions for one or more field-based statistics to be calculated.

Note:

  • outStatistics is supported only on those layers or tables that indicate supportsStatistics is true.

  • If outStatisticFieldName is empty or missing, then the map server will assign a field name to the returned statistic field. A valid field name can only contain alpha-numeric characters and an underscore.

  • When using outStatistics the only other parameters that can be used are groupByFieldsForStatistics, orderByFields, text, time, and where.

  • As of version 10.1, specifying geometry, objectIds, or gdbVersion parameters will return an error.

  • As of version 10.1 SP1, support for the geometry parameter is available.

Values: An array of statistic definitions. A statistic definition specifies the type of statistic, the field on which it is to be calculated, and the resulting output field name.

Syntax:

[
  {
	"statisticType": "<count | sum | min | max | avg | stddev | var>",
	"onStatisticField": "Field1",
	"outStatisticFieldName": "Out_Field_Name1"
  },
  {
	"statisticType": "<count | sum | min | max | avg | stddev | var>",
	"onStatisticField": "Field2",
	"outStatisticFieldName": "Out_Field_Name2"
  }  
]

Example:

[
  {
	"statisticType": "sum",
	"onStatisticField": "GENDER",
	"outStatisticFieldName": "PopulationByGender"
  },
  {
	"statisticType": "avg",
	"onStatisticField": "INCOME",
	"outStatisticFieldName": "AverageIncome"
  }
]

ReturnZ

If true, Z values will be included in the results if the features have Z values. Otherwise, Z values are not returned. The default is false.

Note: This parameter only applies if returnGeometry is true.

ReturnM

If true, M values will be included in the results if the features have Z values. Otherwise, M values are not returned. The default is false.

Note: This parameter only applies if returnGeometry is true.

Geodatabase Version Name

The Geodatabase version to query. This parameter applies only if the hasVersionedData property of the service and the isDataVersioned property of the layers queried are true. If this is not specified, the query will apply to the published map's version.

Syntax: gdbVersion=<geodatabase version>

Example: gdbVersion=sde.USER1

Return Distinct Values

If true then this parameter returns distinct values based on the fields specified in outFields. This parameter applies only if the supportsAdvancedQueries property of the layer is true.

Syntax: returnDistinctValues=<true | false>

Example: returnDistinctValues=true

Result Offset

 

Result Record Count

 

Format

The response format. The default response format is html.

Note: f=kmz will always return Z values.

html | json | kmz | amf (default, when returnIdsOnly=false and returnCountOnly=false)

Values: html | json | amf (when outStatistics is specified)

Values: html | json (when either returnIdsOnly=true or returnCountOnly=true is specified)