Packagecom.esri.ags.tasks
Classpublic class Query

Input parameters for a QueryTask. The query definition requires at least one of the following properties: geometry and/or either text OR where. Optional properties include outFields, outSpatialReference and returnGeometry.

The text property will search the display field of your layer, it is a short hand for a where clause of: where YourDisplayField like '%SearchText%'.


Example
ActionScript code for a query
 var query:Query = new Query();
 query.where = "STATE_NAME = 'Alaska' AND TYPE = 'city'";
 query.returnGeometry = true;
 query.outFields = ["CITY_NAME","AGE_UNDER5","AGE_5_17","AGE_18_64","AGE_65_UP"];

See also

Concepts - Using Query
Live sample - Query on map extent changes.
QueryTask


Public Properties
 PropertyDefined by
  geometry : Geometry
The geometry to apply to the spatial filter.
Query
  outFields : Array
Attribute fields to include in the FeatureSet.
Query
  outSpatialReference : SpatialReference
The well-known ID of the spatial reference for the returned geometry.
Query
  returnGeometry : Boolean
If true, each feature in the FeatureSet includes the geometry.
Query
  spatialRelationship : String = "esriSpatialRelIntersects"
The spatial relationship to be applied on the input geometry while performing the query.
Query
  text : String
Shorthand for a literal search text on the display field, equivalent to: where YourDisplayField like '%SearchText%'.
Query
  where : String
A where clause for the query.
Query
Public Constants
 ConstantDefined by
  SPATIAL_REL_CONTAINS : String = "esriSpatialRelContains"
[static] Part or all of a feature from feature class 1 is contained within a feature from feature class 2.
Query
  SPATIAL_REL_CROSSES : String = "esriSpatialRelCrosses"
[static] The feature from feature class 1 crosses a feature from feature class 2.
Query
  SPATIAL_REL_ENVELOPEINTERSECTS : String = "esriSpatialRelEnvelopeIntersects"
[static] The envelope of feature class 1 intersects with the envelope of feature class 2.
Query
  SPATIAL_REL_INDEXINTERSECTS : String = "esriSpatialRelIndexIntersects"
[static] The envelope of the query feature class intersects the index entry for the target feature class.
Query
  SPATIAL_REL_INTERSECTS : String = "esriSpatialRelIntersects"
[static] Part of a feature from feature class 1 is contained in a feature from feature class 2.
Query
  SPATIAL_REL_OVERLAPS : String = "esriSpatialRelOverlaps"
[static] Features from feature class 1 overlap features in feature class 2.
Query
  SPATIAL_REL_TOUCHES : String = "esriSpatialRelTouches"
[static] The feature from feature class 1 touches the border of a feature from feature class 2.
Query
  SPATIAL_REL_WITHIN : String = "esriSpatialRelWithin"
[static] The feature from feature class 1 is completely enclosed by the feature from feature class 2.
Query
Property detail
geometryproperty
public var geometry:Geometry

The geometry to apply to the spatial filter. The spatial relationship as specified by spatialRelationship is applied to this geometry while performing the query. The valid geometry types are Extent, MapPoint, Multipoint, Polyline, or Polygon.

See also

outFieldsproperty 
public var outFields:Array

Attribute fields to include in the FeatureSet. Fields must exist in the map layer. You must list the actual field names rather than the alias names. Returned fields are also the actual field names. However, you are able to use the alias names when you display the results.

For optimal performance, limit the output fields to only those you expect to use.

Each query must have access to the Shape and Objectid fields for a layer, but your list of fields does not need to include these two fields.

To return all fields, specify the wildcard "*" as the value of this parameter. In this case, the query results include all the field values. Note that the wildcard also implicitly implies returnGeometry=true and setting returnGeometry to false will have no effect.


Example
To ask for specific fields:
     myQuery.outFields = ["CITY_NAME","AGE_UNDER5","AGE_5_17","AGE_18_64","AGE_65_UP"];

To request all fields, use the star wildcard (this implies returnGeometry=true and setting returnGeometry to false will have no effect):
     myQuery.outFields = ["*"];

outSpatialReferenceproperty 
public var outSpatialReference:SpatialReference

The well-known ID of the spatial reference for the returned geometry. If not specified, the geometry is returned in the spatial reference of the map.

returnGeometryproperty 
public var returnGeometry:Boolean

If true, each feature in the FeatureSet includes the geometry. Since the geometry makes up a significant portion of the response, only use when you plan to use the geometry of the feature, for example, to include them on a map. By default, this is false.

spatialRelationshipproperty 
public var spatialRelationship:String = "esriSpatialRelIntersects"

The spatial relationship to be applied on the input geometry while performing the query. See constants below for possible input values.

The default value is SPATIAL_REL_INTERSECTS.

See also

textproperty 
public var text:String

Shorthand for a literal search text on the display field, equivalent to: where YourDisplayField like '%SearchText%'. The search text is case sensitive. This parameter is ignored if the where parameter is specified.

You can determine what the display field is for a layer using the ArcGIS Services Directory.

whereproperty 
public var where:String

A where clause for the query. Any legal SQL where clause operating on the fields in the layer is allowed, for example:
query.where = "POP2000 > 350000".

Constant detail
SPATIAL_REL_CONTAINSconstant
public static const SPATIAL_REL_CONTAINS:String = "esriSpatialRelContains"

Part or all of a feature from feature class 1 is contained within a feature from feature class 2.

SPATIAL_REL_CROSSESconstant 
public static const SPATIAL_REL_CROSSES:String = "esriSpatialRelCrosses"

The feature from feature class 1 crosses a feature from feature class 2.

SPATIAL_REL_ENVELOPEINTERSECTSconstant 
public static const SPATIAL_REL_ENVELOPEINTERSECTS:String = "esriSpatialRelEnvelopeIntersects"

The envelope of feature class 1 intersects with the envelope of feature class 2.

SPATIAL_REL_INDEXINTERSECTSconstant 
public static const SPATIAL_REL_INDEXINTERSECTS:String = "esriSpatialRelIndexIntersects"

The envelope of the query feature class intersects the index entry for the target feature class.

SPATIAL_REL_INTERSECTSconstant 
public static const SPATIAL_REL_INTERSECTS:String = "esriSpatialRelIntersects"

Part of a feature from feature class 1 is contained in a feature from feature class 2.

SPATIAL_REL_OVERLAPSconstant 
public static const SPATIAL_REL_OVERLAPS:String = "esriSpatialRelOverlaps"

Features from feature class 1 overlap features in feature class 2.

SPATIAL_REL_TOUCHESconstant 
public static const SPATIAL_REL_TOUCHES:String = "esriSpatialRelTouches"

The feature from feature class 1 touches the border of a feature from feature class 2.

SPATIAL_REL_WITHINconstant 
public static const SPATIAL_REL_WITHIN:String = "esriSpatialRelWithin"

The feature from feature class 1 is completely enclosed by the feature from feature class 2.