Cookbook: SOW
This section presents common recipes for querying a SOW topic in AMPS using the Command
or Message
interfaces. This section provides information on how to configure the request to AMPS. You can adapt this information to your application and the specific interface you are using.
Command: sow
Basic SOW Query
In its simplest form, a SOW query needs only the topic to query.
SOW Query with Options
In its simplest form, a SOW query needs only the topic to query. To add options to the query, set the Options
header on the Command
.
SOW Query with Ordered Results
In its simplest form, a SOW query needs only the topic to query. To return the results in a specific order, provide an ordering expression in the OrderBy
header.
SOW Query with TopN Results
In its simplest form, a SOW query needs only the topic to query. To return only a specific number of records, provide the number of records to return in the top_n
option.
SOW Query with Content Filter
To provide a content filter on a SOW query, set the Filter
property on the command. The AMPS User Guide provides details on the filter syntax.
Historical SOW Query
To create a historical SOW query, set the Bookmark
property on the command. The property can be either a specific bookmark or a timestamp. The AMPS User Guide provides details on creating timestamps.
This command is only supported on SOW topics that have History
enabled.
Historical SOW Query with Content Filter
To create a historical SOW query, set the Bookmark
property on the command. The property can be either a specific bookmark or a timestamp. The AMPS User Guide provides details on creating timestamps. To add a filter to the query, set the Filter
property on the command. The AMPS User Guide provides details on the filter syntax.
This command is only supported on SOW topics that have History
enabled.
SOW Query for Specific Records
AMPS allows a consumer to query for specific records as identified by a set of SowKeys
. For topics where AMPS assigns the SowKey
, the SowKey
for the record is the AMPS-assigned identifier. For topics configured to require a user-provided SowKey
, the SowKey
for the record is the original key provided when the record was published. The AMPS User Guide provides more details on SOW keys.
SOW Query with Pagination
AMPS allows a consumer to page through records in the SOW using the top_n
and skip_n
options. With this approach, the application uses the top_n
option to limit the number of records returned to a single page worth of records. The application uses the skip_n
option to set the number of records to skip ahead to get to the page to display, and sets the OrderBy
header to specify the ordering for the records. For example, if 10 records fit on a page, and the pages are ordered by the ClientName
field of the records, to display the fourth page, the application would set top_n
to 10
, skip_n
to 30
(to skip the first three pages of records), and OrderBy
to /ClientName
.
Aggregated SOW Query
An aggregated SOW query is a SOW query that provides aggregation options in the options field. To add these options to the subscription, set the Options
header on the Command
.
Last updated