Filtering

The filter property of the Query request provides a single filter or a list of filters.  When more than one filter is provided, they combine with OR and all items matching at least one of the filters are included in the response.

A filter is a string matching an IAP/MQ topic relative to the feedback channel:

dev/lon/myDevice/sts 
Yields the status object of the “myDevice” LonTalk device.

An asterisk is a wildcard for any. This filter:

 dev/lon/*/sts 
Yields the status object for every LonTalk device.

When the asterisk terminates the filter phrase, it includes everything; a filter of: 

dev/lon/myDevice/* 
Yields all objects that belong to the “myDevice” LonTalk device, including its status and configuration objects, and all its interface block objects.

The filter can address properties within objects. For example: 

dev/lon/*/sts/health 
Yields the value of the health property of the status object for every LonTalk device.

dev/lon/myDevice/if/Lamp/*/nviValue/value 
Yields the value of the value property within the nviValue property within every Lamp interface block implemented by the myDevice LonTalk device.

A plus sign is used for additional conditions. It can be read aloud as "but only if".  There can be one or more conditions separated with an ampersand (&) to define an AND combination. Each filter condition consists of a property path, followed by an operator, followed by a value expectation. Both the property path and value expectation can be embedded in a pair of double quotes.

dev/lon/*+"sts/type"=+^(8|9)00001/if/*/*+type=="8000014616000000-4/UFPTsystemMgmt" 
Yields the blocks of type 8000014616000000-4/UFTPsystemMgmt for all devices but only if their sts object contains a type property that matches the ^(8|9)00001 regular expression.

Notice that double quotes are used for phrases containing a forward slash.

dev/lon/*/if/*/*+type=="8000014616000000-4/UFPTsystemMgmt"&"mode/value"==Offnet  
Yields the blocks of type 8000014616000000-4/UFTPsystemMgmt which implement a mode property where the value property reports Offnet.  This query yields the complete interface block.

To retrieve only the datapoint objects matching the same condition, you can use:

dev/lon/*/if/*/*+type=="8000014616000000-4/UFPTsystemMgmt"&"mode/value"==Offnet/mode 
Notice that the first value expectation and the second property path include a forward slash and must therefore be embedded in pairs of double quotes.

Filtering Operators

The following operators are used for filtering a query request:

== (exact match)

!=  (exact mismatch, for a fully specified string)

=+ (regular expression match, case-insensitive)

!+  (regular expression mismatch, case-insensitive)

A single filter implements an AND condition along the hierarchy, evaluated from left to right.  OR combinations, such as queries for one or the other of two application types, use regular expressions.  The regular expression language is defined as the commonly supported aspects of Perl 5 regular expressions. All regular expression matches are case-insensitive.