A predicate is an expression outputs a boolean value. Milvus conducts scalar filtering by searching with predicates. A predicate expression, when evaluated, returns either TRUE or FALSE. View Python SDK API Reference for instruction on using predicate expressions.
An expression can be either NONE or a logical expression.
Expr := LogicalExpr | NIL
|Relational operators||Relational operators use symbols to check for equality, inequality, or relative order between two expressions. Relational operators include
|Logical operators||Logical operators perform a comparison between two expressions. The supported logical operators are: AND, && OR,||, and NOT.|
|IN operator||The IN condition is satisfied when the expression to the left of the keyword IN is included in the list of items.||
Relational operators are symbols that compare one expression with another expression. Data types between left and right side of the operator must match. The supported operators are:
- not equals(!=)
- is greater than (>)
- is greater than or equal to (>=)
- is less than (<)
- is less than or equal to (<=)
There are two types of logical operators, unary and binray. UnaryLogicalOp acts on only one logical expression, while BinaryLogicalOp compares one logic expression with another logic expression. The supported operators are:
- NOT !
- AND &&
- OR ||
LogicalExpr := LogicalExpr BinaryLogicalOp LogicalExpr | UnaryLogicalOp LogicalExpr | "(" LogicalExpr ")" | RelationalExpr | InExpr
The IN operator matches values in a field to any of the items in the constant array, which must be a comma-separated list of items. Data types between left and right side of the operator must match.
InExpr := IDENTIFIER "in" ConstantArray ConstantArray := "[" Constant+, "]"
The order in which the Milvus evaluates predicate expressions follows the table below:
- Expressions inside parentheses
- Not operators
- Or operators
- And Operators
Learn more about Boolean Expression Rules.