How Does the Database Understand and Execute Your Query?


A vector query in Milvus is the process of retrieving vectors via scalar filtering based on a boolean expression. With scalar filtering, users can limit their query results with certain conditions applied to data attributes. For instance, if a user queries for films released during 1990-2010 and scores higher than 8.5, only films whose attributes (release year and score) fulfill the condition.

This post aims to examine how a query is completed in Milvus 2.0 from the input of a query expression to query plan generation and query execution.

Query Expression

Expression of the query with attribute filtering in Milvus adopts the EBNF(Extended Backus–Naur form) syntax. The image below is the expression rules in Milvus.

 Expression syntax.

The EBNF syntax of a logical expression.
Logical expressions can be created using the combination of binary logical operators, unary logical operators, logical expressions, and single expressions. Since EBNF syntax is itself recursive, a logical expression can be the outcome of the combination or part of a bigger logical expression. A logical expression can contain many sub-logical expressions. The same rule applies in Milvus. Suppose a user needs to filter the attributes of the results with many conditions. In that case, the user can create his own set of filtering conditions by combining different logical operators and expressions.

Boolean expression.

CategoriesUncategorized