Historian Point Query Syntax Overview
This section describes the syntax used when parsing the Historian point query strings.
Syntax
The following table lists the query syntax described in Extended Backus-Naur Form (EBNF).
Query | = AndCondition { "OR" AndCondition } ;
|
AndCondition | = QueryFilter { AndOperator QueryFilter } | "(" QueryFilter { AndOperator QueryFilter } ")" ; |
AndOperator | = "AND" | WHITESPACE ;
|
Operator | = EqualOperator | ":<>" | ":<" | ":<=" | ":>" | ":>="
;
|
EqualOperator | = ":" | ":=" ;
|
Wildcard Characters
The string value of a filter can be enclosed in single quotes ('), double quotes ("), or
without quotes. Quotations are required if non-escaped white space or quotation marks are
desired within the filter string. The filter string value can include regular characters and
wildcard characters. Regular characters must match exactly the characters specified in the
filter value. Wildcard characters can be matched with arbitrary fragments of the filter
value.
When the filter value is specified within either single or double quotes, the single
backslash (\) character is treated as a literal character unless followed by a wildcard
character, a single quote ('), or a double quote ("). When specified within quotes, two
quote characters that match the starting quote character are treated as a single quote
character (for example, '' is treated as a one single quote character ' if the filter value
starts with a single quote). When the filter value is specified without quotes, the
backslash character is always used to escape the next character. Therefore, you must use a
double backslash (\\) to match a single backslash when not using quotes around the filter
value.
The supported wildcard characters are "*" to match any zero or more characters and "?" to
match a single character. These characters cannot be escaped using the backslash ("\")
character and will always be used as wildcard characters within the query value.
Operators
The following table lists the operators used in the
AND
condition.Operator | Description | Example |
|---|---|---|
= | The EQUALS operator. | Tag:Tank* or Tag:=Tank* |
<> | The NOT EQUALS operator. | PointType:<>Int32 |
< | The LESS THAN operator. | Descriptor:<M |
<= | The LESS THAN OR EQUAL operator. | Tag:<=Tank |
> | The GREATER THAN operator. | Tag:>Tank |
>= | The GREATER THAN OR EQUAL operator. | Tag:>=Tank |
Examples
The following are some examples of the point attribute queries:
- sin*
- name:sin*
- tag:=sin*
- tag:<>sin* DataType:Float
- tag:<>sin* AND PointType:Float
- step:0 AND PointSource:L
- (tag:<>sin* AND PointType:Float64) OR (tag:="*Tank*" AND DataType:=Int32)
The following are some examples of the point value queries, where they can be combined with attribute queries:
- Value:=1This filter would apply to point value of Numeric, String, and Digital types.
- Value:=AutoThis filter would apply to point value of String and Digital types.
- Value:=abc*This filter would apply to point value of String type.
- Value:="Pt Created"This filter would apply to point value of String and System Digital State types.
- Value:=253 AND IsGood:falseThis filter is an alternative to filtering point value of "Pt Created" System Digital State.
- Value:=tThis filter would apply to point value of String and Timestamp types.
- tag:sin* AND Value:>10
- PointType:Int32 AND Value:>10
- PointType:Float32 AND Value:>10
- DataType:Float64 AND Value:>1.5
- PointType:Blob AND Questionable:true AND TimeStamp:<*
- PointType:Blob AND Value:="Pt Created"
- PointType:Blob AND Value:=253 AND IsGood:false
- PointSource:L AND Annotated:1 AND TimeStamp:t
- IsGood:false AND TimeStamp:<"1/5/2017 1:00:00 AM"
- ChangeDate:>"2/5/2017 2:00:00 AM" AND Step:0 AND IsGood:1
- CreationDate:>y-1d AND Future:true AND TimeStamp:<*
Provide Feedback