Calgary Queries
Queries allow any number of fields to be selected. All fields selected in a query must have an Index built for them.
Queries can be any mixture of ANDs and ORs. And given field can specify any number of values or a begin/end range. In this case it will be an OR within the field. There is no limit to the depth of ANDs and ORs.

<And>
<Or>
<Field name="ZIP" type="list">80303,80304</Field>
<Field name="ZIP" type="list>
<value>80303</value>
<value>80304</value>
</Field>
</Or>
<Field name="Income" type="range" begin="50000" end="750000"/>
<SpatialField name="SpatialObj" type="radius" lat="40" long="-105" radius="10" units="Miles" />
<SpatialField name="SpatialObj" type="binaryIn" spatialInputNum="0" />
<Not>
<Field name="Gender" value="M"/>
</Not>
</And>
Query Types
- And & Or: These groups can contain any number of Field or SpatialField elements or additional And or Or elements.
- Not: Can contain exactly one And, Or, Field, or SpatialField element. The selection will be reversed from what is inside, i.e. if inside you have Gender="M", it will return all genders except M (including NULL and otherwise invalid values). If there is more than 1 child element, it will be an error.
- All: Special tag that selects all records.
- Field: The Field element has a required attribute name which is the field name for this query.
Attribute types
For all index types except spatialObject the attribute type can have the following values:
value (Default): A single exact value will be search for. If no type is specified, it will be presumed to be value. The value attribute or the value of the element will contain the value.
delayedValueNum: Used in place of value if you will be setting a value later with CalgarySetDelayedValue (found in the Calgary API). Can be used to speed up repeated queries.
list: The value attribute or the value of the element will contain a comma separated list of values to query on. If escaping is needed, the each element of the list can be placed within <value>..</value> tags. Value tags are only valid if using list. If not, use the value attribute or the value of the parent element. If using the value tags, the other methods must not be set.
range: There are two additional attributes begin and end that contain the end points. By default it will find value>=begin AND value<end. Optionally includeBegin="True/False" includeEnd="True/False" can be specified to change this behavior.
If leaving the begin or end attribute out or setting it to an empty string, that becomes unbounded.

The single exception to this is string type indexes. If the begin is empty, and includeBegin is false, than the empty string in the index is not part of the result.
begin: This is valid only for string indexes or Full Text (Contains) indexes. Strings are found that start with the query value even if they are longer.
delayedValueBegin: Used in place of begin if you will be setting a value later with CalgarySetDelayedValue (found in the Calgary API). Can be used to speed up repeated queries.
contains: This is valid only for Full Text (Contains) indexes. Strings are found that contain the query value.
end: This is valid only for Full Text (Contains) indexes. Strings are found that end with the query value, even if they are longer.
delayedValueEnd: Used in place of end if you will be setting a value later with CalgarySetDelayedValue (found in the Calgary API). Can be used to speed up repeated queries.
isNull: This is valid for any index type and queries the NULL fields in that index. All index types support querying for NULL. It is the only <Field... /> query type that you can use a spatial field with. For the purpose of spatial indexes, records are considered NULL if they didn't have a valid point, i.e. type None and a point (0,0) are both considered NULL.
listBegin: This is the intersection of list and begin. You can specify a list of things to be queried in begin mode.

SpatialField: The SpatialField Element indexes type has the following values:
radius: The following attributes will be required:
- Latitude
- Longitude
- radius: Either a single number, or a range for donuts, i.e. "3-5".
- units: Miles, Kilometers or Minutes
- dtDataSet: dataset name (or country code) for Drivetime Engine. Omit for default.
binaryIn: the API allows an arbitrary number of spatial objects to be supplied. The attribute spatialInputNum="n" is used to specify which one. If it is not specified, it defaults to 0. Up to 100 separate binary objects can be specified.
file: the attribute dataSource="File or DW2 Connect String" specifies a file or table to take polygons from. The 1st SpatialObj found in the table or file will be the one used for the query. If there are multiple records, they will be OR'd together. Added in r16831.
Allocate: the spatial object will be taken from an Allocate workspace. The dataset is specified via the attribute: dataSet="Software\Alteryx\Portfolio\6.30\Alteryx_US_AGS_08A". The workspace is specified as the text value of the SpatialField element. Added in r16831. If there are multiple spatial objects, they will be OR'd together.