- Build filters using the
FieldandFilterBuilderAPI. - Use every filter type: equality, range, datetime, geo, text, array, and null checks.
- Apply boolean logic:
must,should,must_not, andmin_should. - Compose operators (
&,|, and~) on conditions and builders. - Use standalone conditions:
has_id,has_vector,is_empty,is_null, andnested. - Integrate filters with
points.search,points.query, andpoints.count.
Environment setup
Run the following command to install the required packages:Setup: Create a collection and ingest sample data
Before exploring filters, set up a product catalog collection with rich payload metadata. The steps below create the collection, load five sample products, and define the helper functions used throughout this tutorial.Step 1: Configure and initialize
The following code imports the required modules and defines the embedding helpers used throughout the tutorial. Running it makesembed_text and embed_texts available for converting strings to vectors:
Step 2: Create the collection
The following code creates a cosine-distance collection sized for theall-MiniLM-L6-v2 model. Running it prints a confirmation message once the collection is ready:
Expected output
This block creates theFilter-Tutorial collection with a cosine-distance HNSW index. The get_or_create call is idempotent — running it multiple times will not create duplicate collections. The print confirms the collection is ready before ingestion begins.
Step 3: Ingest sample products
The five products below cover a range of categories, colors, prices, and payload shapes, giving you meaningful filter results throughout the tutorial. Running theingest function embeds all product descriptions and upserts the points into the collection:
Expected output
This block embeds all five product descriptions in a single batch call and upserts them asPointStruct objects, each carrying its source metadata. After upserting, it calls flush to persist the writes to disk, then prints the total number of products ingested.
search runs a filtered vector search against the collection and returns the top-k results. show prints a compact one-line summary per result:
Equality filters
Equality filters match payload values exactly. Use them to constrain results by a specific string, number, boolean, or set of values.Exact match with Field.eq
Field.eq matches a string, integer, or boolean value exactly. Use it when you need results that correspond to one precise value in the payload.
The following code filters the search for “running shoes” to only products where color equals "blue". Running it returns two blue products ranked by vector similarity:
Expected output
The code searches for “running shoes” and applies acolor == "blue" exact-match filter using Field.eq. Only products whose color field is exactly the string "blue" are eligible for ranking. The output returns the two blue products — the SpeedRunner running shoes and the TrailMaster trail running shoes — ranked by their cosine similarity to the query, while the red, white, and black products are excluded.
Field.eq also works on boolean fields. The following code filters the search for “formal leather shoes” to products where in_stock is True. Running it returns only in-stock products, even though the out-of-stock Oxford (id=3) is the most semantically similar:
Expected output
The code searches for “formal leather shoes” and applies anin_stock == True filter. Only products whose in_stock boolean field is True are eligible for ranking. The output shows the four in-stock products sorted by similarity, confirming that the out-of-stock Oxford (id=3) is excluded even though its description is the closest semantic match.
Full-text match with Field.text
Field.text performs token-based matching against text-indexed fields. It requires a TextIndexParams payload index on the field and matches documents that contain the given token anywhere in the indexed content.
The following code filters the search for “outdoor shoes” to products whose text field contains the token "waterproof". Running it returns only the single product whose description includes that word:
Expected output
The code searches for “outdoor shoes” and applies a full-textwaterproof token filter on the text field. Only products whose text description contains the word “waterproof” are eligible for ranking. The output returns a single result — the red hiking boots (id=1) — because it is the only product whose text field includes the word “waterproof.” The trail running shoes (id=4) have “waterproof” in their tags array but not in their text description, so they are excluded by this filter.
IN list with Field.any_of
Field.any_of matches any value in a provided list, equivalent to a SQL IN clause. Pass a list of accepted values to keep only results whose field matches at least one of them.
The following code restricts the search for “comfortable shoes” to products where color is either "blue" or "white". Running it returns three products and excludes the red and black products:
Expected output
The code searches for “comfortable shoes” and applies anany_of(["blue", "white"]) filter on color. Only products whose color is either blue or white pass the filter and are ranked by similarity. The output returns the white UrbanStep sneaker, the blue SpeedRunner, and the blue TrailMaster trail shoe, while the red hiking boots and the black Oxford are excluded.
NOT IN list with Field.except_of
Field.except_of is the inverse of any_of, equivalent to a SQL NOT IN clause. It excludes any point whose field value matches an entry in the provided list.
The following code excludes all products from "TrailMaster" and "ClassicFit" brands. Running it returns only the SpeedRunner and UrbanStep products:
Expected output
The code searches for “shoes” and applies anexcept_of(["TrailMaster", "ClassicFit"]) exclusion filter on brand. Any product belonging to those two brands is removed from the candidate set before similarity ranking. The output returns only the SpeedRunner and the UrbanStep — the two products that belong to neither excluded brand.
Numeric range filters
Range filters constrain results by numeric bounds. You can apply a single bound, a closed range, or a flexible combination of inclusive and exclusive limits.Single-bound range
A single comparison operator filters by one numeric bound. The following code appliesgt(150.0) to the price field. Running it returns only the three products priced above $150:
Expected output
The code searches for “shoes” and applies aprice > 150 single-bound filter using gt(150.0). Only products whose numeric price field strictly exceeds 129.99) and the UrbanStep ($89.99) are excluded.
gte, lt, and lte. The following code applies gte(4.5) to the rating field. Running it returns only products rated 4.5 or higher:
Expected output
The code searches for “shoes” and applies arating >= 4.5 lower-bound filter. Only products whose numeric rating field meets or exceeds 4.5 are returned. The output shows the four qualifying products — the SpeedRunner (4.5), the TrailMaster hiking boot (4.8), the ClassicFit Oxford (4.9), and the trail running shoe (4.6) — ranked by vector similarity, while the UrbanStep (4.2) is excluded.
Closed range with Field.between
Field.between filters within both a lower and upper bound in a single call. Set inclusive=True for a closed range that includes the endpoints, or inclusive=False for an open range that excludes them.
The following code keeps products with a price between 200 inclusive. Running it returns three products and excludes the 249.99 Oxford:
Expected output
The code searches for “shoes” and applies a closed-rangebetween(100.0, 200.0, inclusive=True) filter on price. Products whose price falls at or within the 200 boundary are eligible for ranking. The output returns the three mid-range products while excluding the 249.99 ClassicFit Oxford (above the upper bound).
inclusive=False for an open range (100, 200) that excludes the endpoints.
Flexible range with Field.range
Field.range lets you combine any mix of inclusive and exclusive bounds on the same field in a single call. At least one bound (gt, gte, lt, lte) is required.
The following code keeps products with a rating of 4.0 or higher but strictly below 4.8. Running it returns three products and excludes the 4.8-rated hiking boots and the 4.9-rated Oxford:
Expected output
The code searches for “shoes” and applies arange(gte=4.0, lt=4.8) filter on rating, combining an inclusive lower bound with an exclusive upper bound. Products with a rating of exactly 4.8 or higher are excluded. The output returns the SpeedRunner (4.5), the trail running shoes (4.6), and the UrbanStep (4.2), while the TrailMaster hiking boots (4.8) and the ClassicFit Oxford (4.9) fall outside the allowed range.
Datetime filters
Datetime filters work the same way as numeric range filters but operate on timestamp fields. Use them to restrict results to a specific time window.Single-bound datetime filter
A single datetime bound limits results to points created before or after a given moment. The following code keeps only products with acreated_at value on or after January 1, 2026. Running it returns the three products added in 2026 and excludes the two from 2025:
Expected output
The code searches for “shoes” and applies adatetime_gte filter on created_at, keeping only products whose timestamp is on or after January 1, 2026. Products created in 2025 — the TrailMaster hiking boots (November 2025) and the ClassicFit Oxford (August 2025) — are excluded. The output returns the three products added during 2026, ranked by similarity.
Datetime range with datetime_between
datetime_between keeps only points that fall within a specific date window. Like between for numerics, it accepts an inclusive flag to control whether the boundary timestamps are included or excluded.
The following code keeps only products with a created_at value between October 1 and December 31, 2025 inclusive. Running it returns the single product added during Q4 2025:
Expected output
The code searches for “shoes” and applies adatetime_between filter with inclusive=True that bounds created_at between October 1 and December 31, 2025. Only products whose timestamp falls within Q4 2025 qualify. The output returns a single product — the TrailMaster red hiking boots created on November 20, 2025 — as the only entry within that time window.
Geo filters
Geo filters restrict results to points within a geographic area. The payload field must store{"lat": ..., "lon": ...} objects.
Radius with geo_radius
geo_radius finds all points within a given radius (in metres) of a center coordinate. Use it when you want results within a circular area around a specific location.
The following code restricts the search to products whose location field falls within 500 km of New York City. Running it returns only the single product stored with NYC coordinates:
Expected output
The code searches for “shoes” and applies ageo_radius filter centered on New York City (lat=40.7128, lon=−74.0060) with a 500 km radius. Only products whose location payload falls within that circle are eligible for ranking. The output returns a single product — the SpeedRunner blue running shoes stored at NYC coordinates — as the only product within that geographic area.
Bounding box with geo_bounding_box
geo_bounding_box finds all points within a rectangular geographic region defined by top-left and bottom-right corners. It is faster than a polygon check and useful when the region maps naturally to a lat/lon rectangle.
The following code restricts the search to products located within the Continental US bounding box. Running it returns four products and excludes the Oxford stored in London:
Expected output
The code searches for “shoes” and applies ageo_bounding_box filter defined by a rectangle spanning the Continental United States. Products whose location coordinates fall inside the lat/lon rectangle are included; those outside it are dropped. The output returns four US-based products and excludes the ClassicFit Oxford (id=3), which is stored with London coordinates and lies outside the bounding box.
Polygon with geo_polygon
geo_polygon finds all points within an arbitrary polygon defined by an ordered list of (lat, lon) vertices. The polygon closes automatically, so the first point does not need to be repeated.
The following code restricts the search to products located within a polygon covering the Northeast US. Running it returns only the single product stored with New York City coordinates:
Expected output
The code searches for “shoes” and applies ageo_polygon filter with four vertices that define a rectangular region covering the Northeast United States. Each product’s location is checked against the polygon boundary, and only those that fall inside are ranked. The output returns only the SpeedRunner blue running shoes (id=0), whose New York City coordinates place it squarely within the polygon.
Array cardinality filter
Array cardinality filters restrict results based on the number of elements in an array payload field. Use them when you need to match points with arrays of a specific size.Filter by number of values with values_count
values_count keeps only points whose array field has a number of elements that satisfies the given bounds. Use it to filter by the size of an array such as tags or reviews.
The following code keeps only products with four or more tags. Running it returns only the trail running shoe, which is the only product with four tags:
Expected output
The code searches for “shoes” and applies avalues_count(gte=4) cardinality filter on the tags array. Only products whose tags field contains four or more elements are eligible for ranking. The output shows a single result — the TrailMaster trail running shoe (id=4) — which is the only product in the dataset with exactly four tags.
gte and lte to the same value. The following code keeps only products with exactly three tags. Running it returns the four products that each have exactly three tags:
Expected output
The code searches for “shoes” and applies avalues_count(gte=3, lte=3) filter on tags, which pinpoints products with an array length of exactly three. Setting both bounds to the same value mimics an equality check on array size. The output returns the four products — SpeedRunner, TrailMaster hiking, UrbanStep, and ClassicFit — each of which has precisely three tags in its payload, while the TrailMaster trail running shoe (id=4) is excluded because it has four tags.
values_count supports lt, gt, gte, and lte — at least one bound is required.
Null and empty checks
Null and empty checks let you filter based on whether a payload field exists, is absent, or contains no value. Use them to surface or exclude points with missing or unset data.Check for null with is_null
is_null matches points where a payload field is present but explicitly set to null. Use it to find records that have a field key but no value assigned to it.
The following code keeps products where clearance_note is explicitly null. Running it returns the four non-clearance products and excludes the one Oxford that has a clearance message:
Expected output
The code searches for “shoes” and applies anis_null("clearance_note") condition, which passes only products where clearance_note is present in the payload but explicitly set to null. The filter identifies regular catalogue items with no active clearance. The output returns all four non-clearance products and excludes the ClassicFit Oxford (id=3), whose clearance_note field holds an actual message string.
Check for empty or missing with is_empty
is_empty matches points where an array or string field contains no elements, or where the field key is absent from the payload entirely. Use it to find records with blank or omitted fields.
The following code keeps products where the reviews array is empty. Running it returns only the white casual sneaker, which has no reviews:
Expected output
The code searches for “shoes” and applies anis_empty("reviews") condition, which matches products whose reviews array contains no elements. This filter surfaces products that have not yet received any customer feedback. The output returns only the white UrbanStep casual sneaker (id=2), which was ingested with an empty reviews list.
Point-level conditions
Point-level conditions filter by properties of the point itself rather than its payload fields. Use them to target specific IDs or vector slots without inspecting payload values.Restrict search to specific IDs with has_id
has_id narrows a search to a known subset of point IDs. Use it to apply a pre-filtered allowlist — for example, IDs returned by a business rules layer before the vector search runs.
The following code restricts the search for “comfortable shoes” to points with IDs 0, 2, and 4. Running it returns those three points ranked by similarity, ignoring points 1 and 3 entirely:
Expected output
The code searches for “comfortable shoes” and applies ahas_id([0, 2, 4]) condition that restricts the candidate set to points 0, 2, and 4 before similarity ranking. Points 1 (TrailMaster hiking boots) and 3 (ClassicFit Oxford) are entirely ignored. The output ranks the three allowed points by their cosine similarity to the query, with the white UrbanStep casual sneaker scoring highest for “comfortable shoes”.
Check for a named vector with has_vector
has_vector restricts results to points that carry a particular named vector. Pass an empty string to target the default (unnamed) vector. Use this condition to skip points that are missing a vector slot before performing a search against it.
The following code restricts the search to points that have the default vector populated. Running it prints the number of results, confirming that all five products have a default vector:
Expected output
The code searches for “shoes” and applies ahas_vector("") condition that restricts results to points carrying the default (unnamed) vector. Because every product in this collection was upserted with a default vector, all five points qualify. The output confirms that the result count equals the total number of ingested products.
Nested filters
Thenested condition filters on fields within nested objects. Each item in an array of objects is evaluated independently, so all conditions must be satisfied by the same object — not spread across different objects in the array.
The following code builds an inner filter requiring score >= 5 and verified == True, then wraps it in nested("reviews", ...) so that each review is checked individually. Running it returns products that have at least one review satisfying both conditions at the same time:
Expected output
The code constructs an innerFilterBuilder requiring both score >= 5 and verified == True, then wraps it in nested("reviews", inner). Each review object in a product’s reviews array is checked individually against the inner conditions — both fields must match within the same review object, not across different reviews. The output returns the four products that contain at least one review where a single reviewer gave a verified score of 5: the SpeedRunner (Alex), the TrailMaster hiking boots (Jordan), the ClassicFit Oxford (Morgan), and the TrailMaster trail shoes (Drew). The UrbanStep (id=2) is excluded because its reviews array is empty.
Boolean logic
TheFilterBuilder supports four clause types that control how conditions combine. You can chain them on a single builder to express complex logic.
Require all conditions with must (AND)
must requires every condition in the clause to be satisfied. Points that fail any one condition are excluded. Use it when multiple constraints must all hold simultaneously.
The following code requires color == "blue", in_stock == True, and price < 150 to all be true. Running it returns only the SpeedRunner running shoe, which is the only product satisfying all three conditions:
Expected output
The code chains threemust conditions — color == "blue", in_stock == True, and price < 150 — on a single builder, requiring all three to hold simultaneously. The query embeds “running shoes” and ranks only products that clear every constraint. The output returns a single result: the SpeedRunner blue running shoes (id=0), which is the only product that is blue, currently in stock, and priced below $150.
Accept alternatives with should (OR)
should requires at least one condition in the clause to match. Use it when multiple alternative values are acceptable and any of several criteria is sufficient.
The following code accepts products where color is "blue" or "red". Running it returns three products and excludes the white and black products:
Expected output
The code adds twoshould clauses — one matching blue products and one matching red — so any product satisfying at least one of them is eligible for ranking. The query embeds “outdoor shoes” and scores the qualifying candidates. The output returns the two blue products and the one red product, while the white UrbanStep and the black ClassicFit Oxford are excluded because they match neither condition.
Exclude results with must_not (NOT)
must_not removes any point that matches the condition from the results. Use it to suppress categories or attribute values that should never appear in the output.
The following code requires the footwear category and then excludes both discontinued and formal products. Running it returns four in-catalogue, non-formal products:
Expected output
The code requirescategory == "footwear" via must, then applies two must_not clauses to remove discontinued products and products in the formal sub-category. The query searches for “shoes” and ranks only the candidates that pass all three constraints simultaneously. The output returns four active, non-formal footwear items and excludes the ClassicFit Oxford (id=3), which is both discontinued and categorised as formal.
Match at least N conditions with min_should
min_should qualifies a point when it satisfies at least min_count of the supplied conditions. Use it when partial matches are acceptable and you want to control the minimum number of criteria that must be met.
The following code defines four independent conditions and requires at least three of them to be satisfied. Running it returns the two products that satisfy three or more of the four conditions:
Expected output
The code defines four independent conditions —color == "blue", brand == "TrailMaster", price < 170, and rating >= 4.5 — and passes them to min_should with min_count=3. A product qualifies if it satisfies at least three of the four conditions. The query searches for “trail shoes” and returns two products: the TrailMaster trail running shoe (id=4), which satisfies all four conditions, and the SpeedRunner running shoe (id=0), which satisfies three (blue, price < 170, and rating >= 4.5).
Combining clauses
You can chainmust, should, and must_not on the same builder to express complex logic in a single filter. Each clause type is evaluated independently and the results are intersected.
The following code combines all three clause types: must enforces stock and price constraints, should accepts blue or red products, and must_not excludes discontinued items. Running it returns the three products that satisfy every constraint simultaneously:
Expected output
The code combines all three clause types on a single builder: twomust conditions enforce that the product is in stock and priced between 200, two should conditions accept blue or red products, and one must_not condition rejects discontinued items. The query searches for “shoes for outdoor activities” and ranks only the candidates that clear every constraint simultaneously. The output returns the SpeedRunner (blue, 189.99), and the TrailMaster trail shoes (blue, $159.99), while the UrbanStep (white — fails the color condition) and the ClassicFit Oxford (discontinued, out of stock, and black) are excluded.
Operator composition
Python operators let you combine conditions and builders without calling clause methods directly. This is useful for building filters programmatically from reusable condition variables.Condition operators
You can use Python operators directly on condition objects, which makes filter expressions more concise and readable when constructing filters from named variables. The following code defines three reusable conditions and combinesis_blue and is_cheap with &. Running it returns only the blue SpeedRunner, which is the only product that is both blue and priced below $140:
Expected output
The code defines three named condition objects and combinesis_blue and is_cheap with the & operator, which places both into a must clause. The search for “shoes” ranks only products that are simultaneously blue and priced below 129.99 — because the blue TrailMaster trail shoes at $159.99 exceed the price cap.
is_blue and is_running with |. Running it returns any product that is either blue or in the running sub-category:
Expected output
The code combinesis_blue and is_running with the | operator, which places both into a should clause so that either condition alone is enough to qualify a product. The search for “shoes” returns any product that is blue or belongs to the running sub-category. The output returns the SpeedRunner (blue and running) and the TrailMaster trail shoes (blue), while the white, red, and black products that are neither blue nor in the running sub-category are excluded.
discontinued == True with ~. Running it returns all products that are not discontinued:
Expected output
The code negates thediscontinued == True condition using the ~ prefix operator, which places the condition in must_not. The search for “shoes” returns every product that does not have discontinued set to True, excluding only the ClassicFit Oxford (id=3).
FilterBuilder operators
Operators also work on entireFilterBuilder instances, letting you compose complex filters from simpler named builders.
The following code uses | to OR two builders together. Each builder becomes a nested sub-filter inside should, so running it returns products that are either blue and cheap, or red and premium:
Expected output
The code defines two named builders —blue_and_cheap (blue and price < 150) — and combines them with |. Each builder becomes a nested sub-filter inside a should clause, so any product satisfying either group qualifies. The search for “shoes” returns the SpeedRunner (blue, 189.99, satisfying the second group).
& to AND two builders together, which merges their must, must_not, and should lists into a single filter. Running it returns only products that are both in stock and rated 4.5 or higher:
Expected output
The code AND-joins two separate builders using&, which merges their must lists into a single filter requiring both in_stock == True and rating >= 4.5. The search for “shoes” returns only the three products that are currently in stock and carry a rating of 4.5 or higher, excluding both the out-of-stock Oxford and the lower-rated white sneaker.
~ on a builder to invert it, swapping must into must_not. Running it returns all products that are not discontinued:
Expected output
The code inverts an entireFilterBuilder using ~, which swaps its must clauses into must_not. The resulting filter excludes every product where discontinued == True. The search for “shoes” returns the four active products and omits the ClassicFit Oxford (id=3), which is the only discontinued item.
Using filters with different endpoints
The sameFilterBuilder objects work across all points.* methods. The following sections show the most common patterns.
With points.search
The following code passes a brand filter topoints.search as the filter keyword argument. Running it returns only TrailMaster products ranked by similarity to “hiking boots”:
Expected output
The code builds abrand == "TrailMaster" filter and passes it to points.search via the filter keyword argument. The query embeds “hiking boots” into a vector and ranks only the two TrailMaster products — the red hiking boots (id=1) and the blue trail running shoes (id=4) — by similarity, ignoring all other brands.
With points.query
points.query accepts the same filter argument and supports additional query modes such as sparse or hybrid retrieval. The following code builds an in_stock filter and passes it to points.query. Running it returns the top five in-stock products most similar to “comfortable shoes”:
Expected output
The code builds anin_stock == True filter and passes it to points.query, which embeds “comfortable shoes” and retrieves the top five in-stock products ranked by similarity. The output shows the four in-stock products ordered by their cosine similarity to the query, with the out-of-stock Oxford (id=3) excluded entirely.
With points.count
points.count returns the number of points that match a filter without performing a vector search. The following code runs two counts — one for in-stock products and one for products above $150. Running it prints both totals:
Expected output
The code runs two sequentialpoints.count calls — the first counts products where in_stock == True, and the second counts products where price > 150. Neither call performs a vector search; both return an exact integer count matching the filter. The output confirms that four of the five products are currently in stock and three are priced above $150.
With points.delete
Filters work withpoints.delete to remove all matching points in bulk. The following code builds a filter that targets discontinued and out-of-stock products, counts how many match, and prints the result. Uncomment the delete line to permanently remove those points:
Expected output
The code builds a filter targeting products where bothdiscontinued == True and in_stock == False, then counts matching points using points.count. The delete line is left commented out for safety. The output confirms that exactly one product — the ClassicFit Oxford (id=3) — satisfies both conditions.
With points.set_payload
Filters work withset_payload to update a field on all matching points at once, without fetching, modifying, and re-upserting each point individually. The following code marks every TrailMaster product as featured. Running it updates both TrailMaster points and prints a confirmation:
Expected output
The code builds abrand == "TrailMaster" filter and passes it to points.set_payload, which adds the field featured: True to every matching product without fetching or re-upserting them individually. The output confirms that both TrailMaster products — the red hiking boots (id=1) and the trail running shoes (id=4) — were updated in a single server-side operation.
Utility methods
FilterBuilder provides a few convenience methods for inspecting and branching filter logic.
Check whether a builder has conditions with is_empty
FilterBuilder.is_empty() returns True if no conditions have been added to the builder. The following code checks the same builder before and after adding a condition. Running it prints True for the empty builder and False after the condition is added:
Expected output
The code callsis_empty() on a freshly instantiated FilterBuilder before and after appending a must condition. The first call returns True because no conditions have been added. The second call returns False after the color == "blue" condition is appended, confirming that the builder now holds at least one clause.
Branch filter logic with copy
FilterBuilder.copy() creates a shallow copy of the builder so you can derive multiple filter variants from a shared base without mutating the original.
The following code creates a base filter for in-stock products and branches it into two separate filters — one for blue products and one for red. Running it prints each builder’s condition count, confirming that the base remains unchanged at one condition while each branch has two:
Expected output
The code creates a base builder with a singlein_stock == True condition, then uses copy() to derive two independent branches — one that also requires color == "blue" and one that requires color == "red". The output shows that the base builder retains its original one condition while each branch now holds two, confirming that copy() creates a true independent snapshot rather than a shared reference.
Test truthiness with bool
FilterBuilder evaluates to True when it has at least one condition and False when empty. The following code checks an empty builder and prints a message when no filters have been configured:
Expected output
The code instantiates an emptyFilterBuilder and checks its boolean truthiness with if not fb. Because no conditions have been added, the builder evaluates to False, and the guard message is printed. This pattern is useful in application code to decide at runtime whether to pass a filter to the search call or skip it entirely.
Complete filter reference
The following tables summarize every available method and operator in the Filter DSL.Field conditions
The table below lists every method available on aField object, along with the filter type and a short example:
| Method | Type | Example |
|---|---|---|
eq(value) | Exact match (str, int, bool) | Field("color").eq("blue") |
text(value) | Full-text token match | Field("description").text("waterproof") |
any_of(values) | IN list | Field("color").any_of(["blue", "red"]) |
except_of(values) | NOT IN list | Field("brand").except_of(["X", "Y"]) |
gt(value) | Greater than | Field("price").gt(100.0) |
gte(value) | Greater than or equal | Field("rating").gte(4.5) |
lt(value) | Less than | Field("price").lt(200.0) |
lte(value) | Less than or equal | Field("rating").lte(5.0) |
between(lo, hi) | Closed/open range | Field("price").between(50, 150) |
range(gt=, gte=, lt=, lte=) | Flexible bounds | Field("price").range(gte=50, lt=200) |
datetime_gt(dt) | After datetime | Field("created").datetime_gt(dt) |
datetime_gte(dt) | At or after datetime | Field("created").datetime_gte(dt) |
datetime_lt(dt) | Before datetime | Field("created").datetime_lt(dt) |
datetime_lte(dt) | At or before datetime | Field("created").datetime_lte(dt) |
datetime_between(lo, hi) | Datetime range | Field("created").datetime_between(lo, hi) |
values_count(gte=, lte=, ...) | Array cardinality | Field("tags").values_count(gte=3) |
geo_radius(lat, lon, r) | Circle (metres) | Field("loc").geo_radius(40.7, -74.0, 5000) |
geo_bounding_box(tl, br) | Rectangle | Field("loc").geo_bounding_box((49,-125),(25,-66)) |
geo_polygon(exterior) | Polygon | Field("loc").geo_polygon([(a,b),(c,d),...]) |
Standalone conditions
The following functions are imported directly and passed to.must(), .should(), or .must_not():
| Function | Purpose | Example |
|---|---|---|
is_null(key) | Field is null | is_null("notes") |
is_empty(key) | Field is empty or missing | is_empty("reviews") |
has_id(ids) | Point ID in list | has_id([0, 1, 2]) |
has_vector(name) | Named vector exists | has_vector("image") |
nested(key, filter) | Nested object filter | nested("reviews", inner_fb) |
FilterBuilder clauses
Each clause method appends conditions to the corresponding logical group:| Method | Logic | Effect |
|---|---|---|
.must(cond) | AND | All must conditions required |
.should(cond) | OR | At least one should condition |
.must_not(cond) | NOT | Exclude matching |
.min_should(conds, N) | N-of-M | At least N conditions match |
Operators
Python operators work on both individual conditions andFilterBuilder instances:
| Operator | On condition | On FilterBuilder |
|---|---|---|
a & b | must=[a, b] | Merge lists |
a | b | should=[a, b] | Nested sub-filters in should |
~a | must_not=[a] | Swap must and must_not |
Next steps
Hybrid search patterns
Combine vector similarity with structured constraints
Similarity search basics
Learn the core retrieval workflow
Filtering with boolean logic
Add
must, should, and must_not conditionsGeospatial search
Make retrieval location-aware