Overview of SODA Filter Specifications

A filter specification is a pattern expressed in JSON. You use it to select, from a collection, the JSON documents whose content matches it, meaning that the condition expressed by the pattern evaluates to true for the content of (only) those documents.

Because a filter selects documents from a collection, you can use it to drive read and write operations on those documents. For example, you can use a filer to remove all matching documents from a collection.

Each SODA implementation that supports query-by-example provides its own way to query JSON documents. They all use a SODA filter specification to define the data to be queried. For example, with SODA for REST you use an HTTP POST request, passing URI argument action=query, and providing the filter specification in the POST body.

Note: In general, a filter is for querying JSON documents. Filter operators $id and $textContains can exceptionally be used with a heterogeneous collection, that is, a collection that has the media type column. Operator $textContains can only be used with a heterogeneous collection. (A heterogeneous collection can, but it need not, contain JSON documents.)

SODA for Java and SODA for REST do not support operator $textContains, and they do not support operator $id for use with a heterogeneous collection.

Filter patterns use operators for this document selection or matching, including condition operators, which perform operations such as field-value comparison or testing for field existence, and logical combining operators for union ($or) and intersection ($and).

A filter operator occurs in a filter as a field of a JSON object. The associated field value is the operand on which the operator acts. SODA operators are predefined fields whose names start with a dollar sign, $.

For example, in this filter, the object that is the value of field age has as its only field the operator $gt, and the associated operand is the numeric value 45:

{ "age" : { "$gt": 45 } }

There are different kinds of filter operators. In particular, there are operators that do the following kinds of things. (This is not an exhaustive list of filter operators.)

See Also:

Related Topics