---
title: Boolean
---
## Basic Usage
Boolean queries filter documents based on the logical relationships defined by their subqueries, considering:
- Documents that satisfy all `must` conditions.
- Documents that satisfy none of the `must_not` conditions.
- Documents that satisfy at least one condition from either `must` or `should`.
Boolean queries are a powerful way to combine the results of several different queries.
Here's the code wrapped in a CodeGroup with both SQL function and JSON syntax:
```sql Function Syntax
SELECT description, rating, category
FROM mock_items
WHERE id @@@ paradedb.boolean(
should => ARRAY[
paradedb.term('description', 'headphones')
],
must => ARRAY[
paradedb.term('category', 'electronics'),
paradedb.fuzzy_term('description', 'bluetooht')
],
must_not => ARRAY[
paradedb.range('rating', int4range(NULL, 2, '()'))
]
);
```
```sql JSON Syntax
SELECT description, rating, category
FROM mock_items
WHERE id @@@
'{
"boolean": {
"should": [
{"term": {"field": "description", "value": "headphones"}}
],
"must": [
{
"term": {
"field": "category",
"value": "electronics"
}
},
{"fuzzy_term": {"field": "description", "value": "bluetooht"}}
],
"must_not": [
{
"range": {
"field": "rating",
"from": null,
"to": 2,
"bounds": "()"
}
}
]
}
}'::jsonb;
```
A query object or an `ARRAY` of query objects as conditions which must be
matched.
A query object or an `ARRAY` of query objects as conditions which must not be
matched.
A query object or an `ARRAY` of query objects as conditions of which at least
one must be matched.
In order for a boolean query to return a result, one of `must` or `should` must be provided.
`must_not` acts as a mask and does not produce a result set.