Skip to navigation

Filtering Content

Add filter metadata to each document during ingest. GroundX copies it to every chunk so you can restrict which documents a search returns.

Include a filter expression when searching a bucket to return only matching documents. Without a filter expression, search includes the entire bucket.

Supported metadata types

Filter metadata must be a JSON object with string keys. Values can be:

  • String
  • Number (integers and decimals are stored as 64-bit floating-point values)
  • Boolean (true or false)
  • List of strings or numbers
  • Nested objects following the same rules

These metadata objects are valid:

JSON
{
"security_level": 1,
"organization": "corporate",
"roles": ["director","executive"]
}
JSON
{
"permissions": {
"security_level": 1,
"organization": "corporate",
"roles": ["director","executive"]
},
"graph": {
"nodes": ["corporate policy","version 1.0.112"]
}
}

Filter Metadata Size

Filter metadata is limited to 40 KB per document.

Filter Query Syntax

Filter queries are based on MongoDB’s query and projection operators. GroundX supports a subset of these selectors:

FilterDescriptionSupported types
$eqMatches documents with filter values that are equal to a specified value. Example: {"roles": {"$eq": "director"}}Number, string, boolean
$neMatches documents with filter values that are not equal to a specified value. Example: {"roles": {"$ne": "executive"}}Number, string, boolean
$gtMatches documents with filter values that are greater than a specified value. Example: {"security_level": {"$gt": 1}}Number
$gteMatches documents with filter values that are greater than or equal to a specified value. Example:{"security_level": {"$gte": 1}}Number
$ltMatches documents with filter values that are less than a specified value. Example: {"security_level": {"$lt": 1}}Number
$lteMatches documents with filter values that are less than or equal to a specified value. Example: {"security_level": {"$lte": 1}}Number
$inMatches documents with filter values that are in a specified array. Example: {"roles": {"$in": ["director", "executive"]}}String, number
$ninMatches documents with filter values that are not in a specified array. Example: {"roles": {"$nin": ["director", "executive"]}}String, number
$existsMatches documents with the specified filter field. Example: {"roles": {"$exists": true}}Number, string, boolean
$andJoins query clauses with a logical AND. Example: {"$and": [{"roles": {"$eq": "executive"}}, {"security_level": {"$gte": 1}}]}-
$orJoins query clauses with a logical OR. Example: {"$or": [{"roles": {"$eq": "executive"}}, {"security_level": {"$gte": 1}}]}-

This document’s filter metadata includes a "roles" list:

JSON
{ "roles": ["director", "executive"] }

The document has both "director" and "executive" roles. All these queries match it:

JSON
{"roles":"director"}
JSON
{"roles": {"$in":["director","executive","employee"]}}
JSON
{"$and": [{"roles": "director"}, {"roles":"executive"}]}

This query does not match:

JSON
{ "$and": [{ "roles": "director" }, { "roles": "employee" }] }

These invalid queries return an error:

JSON
# INVALID QUERY:
{"roles": [true, false]}
JSON
# INVALID QUERY:
{"roles": {"$eq": ["director", "employee"]}}