Logical filtering
Logical expressions are the cornerstone of any query language and evitaDB is no different. They allow you to combine multiple filter expressions into one unambiguous expression.
What if the logical binding is not set explicitly?
To make the query language more concise, we omit logical binding in container-type filtering constraints and assume
a logical conjunctive relation "and at the same time" (and) unless an explicit binding is set.
For example, you can issue the following query:
As you can see - there is no logical binding between entityPrimaryKeyInSet and attributeEquals constraints, and for
this case the logical conjunction will be applied, which will result in a single returned product with code
lenovo-thinkpad-t495-2 in the response.
And
- filterConstraint:any+
one or more mandatory filter constraints that will produce logical conjunction
The container represents
a logical conjunction, that is demonstrated on following table:
A | B | A ∧ B |
---|---|---|
True | True | True |
True | False | False |
False | True | False |
False | False | False |
The following query:
... returns a single result - product with entity primary key 106742, which is the only one that all three
entityPrimaryKeyInSet constraints have in common.
Or
- filterConstraint:any+
one or more mandatory filter constraints that will produce logical disjunction
The container represents
a logical disjunction, that is demonstrated on following table:
A | B | A ∨ B |
---|---|---|
True | True | True |
True | False | True |
False | True | True |
False | False | False |
The following query:
... returns four results representing a combination of all primary keys used in the entityPrimaryKeyInSet constraints.
Not
- filterConstraint:any!
one or more mandatory filter constraints that will be subtracted from the superset of all entities
The container represents
a logical negation, that is demonstrated on following table:
A | ¬ A |
---|---|
True | False |
False | True |
The following query:
... returns thousands of results excluding the entities with primary keys mentioned in entityPrimaryKeyInSet constraint.
Because this situation is hard to visualize - let's narrow our super set to only a few entities:
... which returns only three products that were not excluded by the following not constraint.