Skip to content

Filters

Filter configuration and compilation.

Base Filter

BaseFilter pydantic-model

Base class for all filter configurations in the Config schema.

Attributes:

Name Type Description
alias str | None

An optional alias for the filter, used for display purposes.

disabled bool | None

Indicates whether the filter is disabled. If true, the filter will not be applied.

Show JSON schema:
{
  "additionalProperties": false,
  "description": "Base class for all filter configurations in the Config schema.",
  "properties": {
    "alias": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An optional alias for the filter, used for display purposes.",
      "title": "Alias"
    },
    "disabled": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
      "title": "Disabled"
    }
  },
  "title": "BaseFilter",
  "type": "object"
}

Config:

  • strict: True
  • validate_default: True
  • extra: forbid
  • use_enum_values: True
  • frozen: True
  • use_attribute_docstrings: True
  • serialize_by_alias: True
Source code in kb_dashboard_core/filters/config.py
class BaseFilter(BaseCfgModel):
    """Base class for all filter configurations in the Config schema."""

    alias: str | None = Field(None)
    """An optional alias for the filter, used for display purposes."""

    disabled: bool | None = Field(None)
    """Indicates whether the filter is disabled. If `true`, the filter will not be applied."""

Exists Filter

ExistsFilter pydantic-model

Represents an 'exists' filter configuration in the Config schema.

This filter checks for the existence or non-existence of a specific field.

Attributes:

Name Type Description
exists str

The field name to check for existence. If the field exists in a document, it will match that document.

Show JSON schema:
{
  "additionalProperties": false,
  "description": "Represents an 'exists' filter configuration in the Config schema.\n\nThis filter checks for the existence or non-existence of a specific field.",
  "properties": {
    "alias": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An optional alias for the filter, used for display purposes.",
      "title": "Alias"
    },
    "disabled": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
      "title": "Disabled"
    },
    "exists": {
      "description": "The field name to check for existence. If the field exists in a document, it will match that document.",
      "title": "Exists",
      "type": "string"
    }
  },
  "required": [
    "exists"
  ],
  "title": "ExistsFilter",
  "type": "object"
}
Source code in kb_dashboard_core/filters/config.py
class ExistsFilter(BaseFilter):
    """Represents an 'exists' filter configuration in the Config schema.

    This filter checks for the existence or non-existence of a specific field.
    """

    exists: str = Field(...)
    """The field name to check for existence. If the field exists in a document, it will match that document."""

Custom Filter

CustomFilter pydantic-model

Represents a custom filter configuration in the Config schema.

This filter allows for custom query definitions that do not fit into the standard filters.

Attributes:

Name Type Description
dsl dict[str, Any]

The custom query definition. This should be a valid Elasticsearch query object.

Show JSON schema:
{
  "additionalProperties": false,
  "description": "Represents a custom filter configuration in the Config schema.\n\nThis filter allows for custom query definitions that do not fit into the standard filters.",
  "properties": {
    "alias": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An optional alias for the filter, used for display purposes.",
      "title": "Alias"
    },
    "disabled": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
      "title": "Disabled"
    },
    "dsl": {
      "additionalProperties": true,
      "description": "The custom query definition. This should be a valid Elasticsearch query object.",
      "title": "Dsl",
      "type": "object"
    }
  },
  "required": [
    "dsl"
  ],
  "title": "CustomFilter",
  "type": "object"
}
Source code in kb_dashboard_core/filters/config.py
class CustomFilter(BaseFilter):
    """Represents a custom filter configuration in the Config schema.

    This filter allows for custom query definitions that do not fit into the standard filters.
    """

    dsl: dict[str, Any] = Field(...)
    """The custom query definition. This should be a valid Elasticsearch query object."""

Phrase Filter

PhraseFilter pydantic-model

Represents a 'phrase' filter configuration in the Config schema.

This filter matches documents where a specific field contains an exact phrase.

Attributes:

Name Type Description
field str

The field name to apply the filter to.

equals FilterScalar

The exact phrase value that the field must match.

Show JSON schema:
{
  "$defs": {
    "FilterScalar": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        }
      ]
    }
  },
  "additionalProperties": false,
  "description": "Represents a 'phrase' filter configuration in the Config schema.\n\nThis filter matches documents where a specific field contains an exact phrase.",
  "properties": {
    "alias": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An optional alias for the filter, used for display purposes.",
      "title": "Alias"
    },
    "disabled": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
      "title": "Disabled"
    },
    "field": {
      "description": "The field name to apply the filter to.",
      "title": "Field",
      "type": "string"
    },
    "equals": {
      "$ref": "#/$defs/FilterScalar",
      "description": "The exact phrase value that the field must match."
    }
  },
  "required": [
    "field",
    "equals"
  ],
  "title": "PhraseFilter",
  "type": "object"
}
Source code in kb_dashboard_core/filters/config.py
class PhraseFilter(BaseFilter):
    """Represents a 'phrase' filter configuration in the Config schema.

    This filter matches documents where a specific field contains an exact phrase.
    """

    field: str = Field(...)
    """The field name to apply the filter to."""

    equals: FilterScalar = Field(...)
    """The exact phrase value that the field must match."""

Phrases Filter

PhrasesFilter pydantic-model

Represents a 'phrases' filter configuration in the Config schema.

This filter matches documents where a specific field contains one or more of the specified phrases.

Attributes:

Name Type Description
field str

The field name to apply the filter to.

in_list list[FilterScalar]

A list of phrases. Documents must match at least one of these phrases in the specified field.

Show JSON schema:
{
  "$defs": {
    "FilterScalar": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        }
      ]
    }
  },
  "additionalProperties": false,
  "description": "Represents a 'phrases' filter configuration in the Config schema.\n\nThis filter matches documents where a specific field contains one or more\nof the specified phrases.",
  "properties": {
    "alias": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An optional alias for the filter, used for display purposes.",
      "title": "Alias"
    },
    "disabled": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
      "title": "Disabled"
    },
    "field": {
      "description": "The field name to apply the filter to.",
      "title": "Field",
      "type": "string"
    },
    "in": {
      "description": "A list of phrases. Documents must match at least one of these phrases in the specified field.",
      "items": {
        "$ref": "#/$defs/FilterScalar"
      },
      "title": "In",
      "type": "array"
    }
  },
  "required": [
    "field",
    "in"
  ],
  "title": "PhrasesFilter",
  "type": "object"
}
Source code in kb_dashboard_core/filters/config.py
class PhrasesFilter(BaseFilter):
    """Represents a 'phrases' filter configuration in the Config schema.

    This filter matches documents where a specific field contains one or more
    of the specified phrases.
    """

    field: str = Field(...)
    """The field name to apply the filter to."""

    in_list: list[FilterScalar] = Field(..., alias='in')
    """A list of phrases. Documents must match at least one of these phrases in the specified field."""

Range Filter

RangeFilter pydantic-model

Represents a 'range' filter configuration in the Config schema.

This filter matches documents where a numeric or date field falls within a specified range.

Attributes:

Name Type Description
field str

The field name to apply the filter to.

gte FilterScalar | None

Greater than or equal to value for the range filter.

lte FilterScalar | None

Less than or equal to value for the range filter.

lt FilterScalar | None

Less than value for the range filter.

gt FilterScalar | None

Greater than value for the range filter.

Show JSON schema:
{
  "$defs": {
    "FilterScalar": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        }
      ]
    }
  },
  "additionalProperties": false,
  "description": "Represents a 'range' filter configuration in the Config schema.\n\nThis filter matches documents where a numeric or date field falls within a specified range.",
  "properties": {
    "alias": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An optional alias for the filter, used for display purposes.",
      "title": "Alias"
    },
    "disabled": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
      "title": "Disabled"
    },
    "field": {
      "description": "The field name to apply the filter to.",
      "title": "Field",
      "type": "string"
    },
    "gte": {
      "anyOf": [
        {
          "$ref": "#/$defs/FilterScalar"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Greater than or equal to value for the range filter."
    },
    "lte": {
      "anyOf": [
        {
          "$ref": "#/$defs/FilterScalar"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Less than or equal to value for the range filter."
    },
    "lt": {
      "anyOf": [
        {
          "$ref": "#/$defs/FilterScalar"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Less than value for the range filter."
    },
    "gt": {
      "anyOf": [
        {
          "$ref": "#/$defs/FilterScalar"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Greater than value for the range filter."
    }
  },
  "required": [
    "field"
  ],
  "title": "RangeFilter",
  "type": "object"
}

Validators:

Source code in kb_dashboard_core/filters/config.py
class RangeFilter(BaseFilter):
    """Represents a 'range' filter configuration in the Config schema.

    This filter matches documents where a numeric or date field falls within a specified range.
    """

    field: str = Field(...)
    """The field name to apply the filter to."""

    gte: FilterScalar | None = Field(default=None)
    """Greater than or equal to value for the range filter."""

    lte: FilterScalar | None = Field(default=None)
    """Less than or equal to value for the range filter."""

    lt: FilterScalar | None = Field(default=None)
    """Less than value for the range filter."""

    gt: FilterScalar | None = Field(default=None)
    """Greater than value for the range filter."""

    @model_validator(mode='after')
    def at_least_one_value(self) -> Self:
        """Ensure at least one of gte, lte, gt, or lt is provided."""
        if all(value is None for value in (self.lte, self.gte, self.gt, self.lt)):
            msg = "At least one of 'gte', 'lte', 'gt', or 'lt' must be provided for RangeFilter."
            raise ValueError(msg)
        return self

Negate Filter

NegateFilter pydantic-model

Represents a negated filter configuration in the Config schema.

This allows for excluding documents that match the nested filter.

Note: Unlike other filter types, NegateFilter extends BaseCfgModel directly rather than BaseFilter, so it does not support 'alias' or 'disabled' fields. This is intentional - negation is a logical modifier that wraps another filter, and aliasing/disabling should be applied to the wrapped filter itself.

Attributes:

Name Type Description
not_filter FilterTypes

The filter to negate. Can be a phrase, phrases, or range filter.

Show JSON schema:
{
  "$defs": {
    "AndFilter": {
      "additionalProperties": false,
      "description": "Represents an 'and' filter configuration in the Config schema.\n\nThis filter matches documents that satisfy all of the specified filters.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "and": {
          "description": "A list of filters. All filters must match for a document to be included.",
          "items": {
            "$ref": "#/$defs/FilterTypes"
          },
          "title": "And",
          "type": "array"
        }
      },
      "required": [
        "and"
      ],
      "title": "AndFilter",
      "type": "object"
    },
    "CustomFilter": {
      "additionalProperties": false,
      "description": "Represents a custom filter configuration in the Config schema.\n\nThis filter allows for custom query definitions that do not fit into the standard filters.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "dsl": {
          "additionalProperties": true,
          "description": "The custom query definition. This should be a valid Elasticsearch query object.",
          "title": "Dsl",
          "type": "object"
        }
      },
      "required": [
        "dsl"
      ],
      "title": "CustomFilter",
      "type": "object"
    },
    "ExistsFilter": {
      "additionalProperties": false,
      "description": "Represents an 'exists' filter configuration in the Config schema.\n\nThis filter checks for the existence or non-existence of a specific field.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "exists": {
          "description": "The field name to check for existence. If the field exists in a document, it will match that document.",
          "title": "Exists",
          "type": "string"
        }
      },
      "required": [
        "exists"
      ],
      "title": "ExistsFilter",
      "type": "object"
    },
    "FilterScalar": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        }
      ]
    },
    "FilterTypes": {
      "oneOf": [
        {
          "$ref": "#/$defs/ExistsFilter"
        },
        {
          "$ref": "#/$defs/PhraseFilter"
        },
        {
          "$ref": "#/$defs/PhrasesFilter"
        },
        {
          "$ref": "#/$defs/RangeFilter"
        },
        {
          "$ref": "#/$defs/CustomFilter"
        },
        {
          "$ref": "#/$defs/AndFilter"
        },
        {
          "$ref": "#/$defs/OrFilter"
        },
        {
          "$ref": "#/$defs/NegateFilter"
        }
      ]
    },
    "NegateFilter": {
      "additionalProperties": false,
      "description": "Represents a negated filter configuration in the Config schema.\n\nThis allows for excluding documents that match the nested filter.\n\nNote: Unlike other filter types, NegateFilter extends BaseCfgModel directly\nrather than BaseFilter, so it does not support 'alias' or 'disabled' fields.\nThis is intentional - negation is a logical modifier that wraps another filter,\nand aliasing/disabling should be applied to the wrapped filter itself.",
      "properties": {
        "not": {
          "$ref": "#/$defs/FilterTypes",
          "description": "The filter to negate. Can be a phrase, phrases, or range filter."
        }
      },
      "required": [
        "not"
      ],
      "title": "NegateFilter",
      "type": "object"
    },
    "OrFilter": {
      "additionalProperties": false,
      "description": "Represents an 'or' filter configuration in the Config schema.\n\nThis filter matches documents that satisfy at least one of the specified filters.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "or": {
          "description": "A list of filters. At least one filter must match for a document to be included.",
          "items": {
            "$ref": "#/$defs/FilterTypes"
          },
          "title": "Or",
          "type": "array"
        }
      },
      "required": [
        "or"
      ],
      "title": "OrFilter",
      "type": "object"
    },
    "PhraseFilter": {
      "additionalProperties": false,
      "description": "Represents a 'phrase' filter configuration in the Config schema.\n\nThis filter matches documents where a specific field contains an exact phrase.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "field": {
          "description": "The field name to apply the filter to.",
          "title": "Field",
          "type": "string"
        },
        "equals": {
          "$ref": "#/$defs/FilterScalar",
          "description": "The exact phrase value that the field must match."
        }
      },
      "required": [
        "field",
        "equals"
      ],
      "title": "PhraseFilter",
      "type": "object"
    },
    "PhrasesFilter": {
      "additionalProperties": false,
      "description": "Represents a 'phrases' filter configuration in the Config schema.\n\nThis filter matches documents where a specific field contains one or more\nof the specified phrases.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "field": {
          "description": "The field name to apply the filter to.",
          "title": "Field",
          "type": "string"
        },
        "in": {
          "description": "A list of phrases. Documents must match at least one of these phrases in the specified field.",
          "items": {
            "$ref": "#/$defs/FilterScalar"
          },
          "title": "In",
          "type": "array"
        }
      },
      "required": [
        "field",
        "in"
      ],
      "title": "PhrasesFilter",
      "type": "object"
    },
    "RangeFilter": {
      "additionalProperties": false,
      "description": "Represents a 'range' filter configuration in the Config schema.\n\nThis filter matches documents where a numeric or date field falls within a specified range.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "field": {
          "description": "The field name to apply the filter to.",
          "title": "Field",
          "type": "string"
        },
        "gte": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterScalar"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Greater than or equal to value for the range filter."
        },
        "lte": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterScalar"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Less than or equal to value for the range filter."
        },
        "lt": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterScalar"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Less than value for the range filter."
        },
        "gt": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterScalar"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Greater than value for the range filter."
        }
      },
      "required": [
        "field"
      ],
      "title": "RangeFilter",
      "type": "object"
    }
  },
  "$ref": "#/$defs/NegateFilter"
}
Source code in kb_dashboard_core/filters/config.py
class NegateFilter(BaseCfgModel):
    """Represents a negated filter configuration in the Config schema.

    This allows for excluding documents that match the nested filter.

    Note: Unlike other filter types, NegateFilter extends BaseCfgModel directly
    rather than BaseFilter, so it does not support 'alias' or 'disabled' fields.
    This is intentional - negation is a logical modifier that wraps another filter,
    and aliasing/disabling should be applied to the wrapped filter itself.
    """

    not_filter: 'FilterTypes' = Field(..., validation_alias='not')
    """The filter to negate. Can be a phrase, phrases, or range filter."""

And Filter

AndFilter pydantic-model

Represents an 'and' filter configuration in the Config schema.

This filter matches documents that satisfy all of the specified filters.

Attributes:

Name Type Description
and_filters list[FilterTypes]

A list of filters. All filters must match for a document to be included.

Show JSON schema:
{
  "$defs": {
    "AndFilter": {
      "additionalProperties": false,
      "description": "Represents an 'and' filter configuration in the Config schema.\n\nThis filter matches documents that satisfy all of the specified filters.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "and": {
          "description": "A list of filters. All filters must match for a document to be included.",
          "items": {
            "$ref": "#/$defs/FilterTypes"
          },
          "title": "And",
          "type": "array"
        }
      },
      "required": [
        "and"
      ],
      "title": "AndFilter",
      "type": "object"
    },
    "CustomFilter": {
      "additionalProperties": false,
      "description": "Represents a custom filter configuration in the Config schema.\n\nThis filter allows for custom query definitions that do not fit into the standard filters.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "dsl": {
          "additionalProperties": true,
          "description": "The custom query definition. This should be a valid Elasticsearch query object.",
          "title": "Dsl",
          "type": "object"
        }
      },
      "required": [
        "dsl"
      ],
      "title": "CustomFilter",
      "type": "object"
    },
    "ExistsFilter": {
      "additionalProperties": false,
      "description": "Represents an 'exists' filter configuration in the Config schema.\n\nThis filter checks for the existence or non-existence of a specific field.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "exists": {
          "description": "The field name to check for existence. If the field exists in a document, it will match that document.",
          "title": "Exists",
          "type": "string"
        }
      },
      "required": [
        "exists"
      ],
      "title": "ExistsFilter",
      "type": "object"
    },
    "FilterScalar": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        }
      ]
    },
    "FilterTypes": {
      "oneOf": [
        {
          "$ref": "#/$defs/ExistsFilter"
        },
        {
          "$ref": "#/$defs/PhraseFilter"
        },
        {
          "$ref": "#/$defs/PhrasesFilter"
        },
        {
          "$ref": "#/$defs/RangeFilter"
        },
        {
          "$ref": "#/$defs/CustomFilter"
        },
        {
          "$ref": "#/$defs/AndFilter"
        },
        {
          "$ref": "#/$defs/OrFilter"
        },
        {
          "$ref": "#/$defs/NegateFilter"
        }
      ]
    },
    "NegateFilter": {
      "additionalProperties": false,
      "description": "Represents a negated filter configuration in the Config schema.\n\nThis allows for excluding documents that match the nested filter.\n\nNote: Unlike other filter types, NegateFilter extends BaseCfgModel directly\nrather than BaseFilter, so it does not support 'alias' or 'disabled' fields.\nThis is intentional - negation is a logical modifier that wraps another filter,\nand aliasing/disabling should be applied to the wrapped filter itself.",
      "properties": {
        "not": {
          "$ref": "#/$defs/FilterTypes",
          "description": "The filter to negate. Can be a phrase, phrases, or range filter."
        }
      },
      "required": [
        "not"
      ],
      "title": "NegateFilter",
      "type": "object"
    },
    "OrFilter": {
      "additionalProperties": false,
      "description": "Represents an 'or' filter configuration in the Config schema.\n\nThis filter matches documents that satisfy at least one of the specified filters.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "or": {
          "description": "A list of filters. At least one filter must match for a document to be included.",
          "items": {
            "$ref": "#/$defs/FilterTypes"
          },
          "title": "Or",
          "type": "array"
        }
      },
      "required": [
        "or"
      ],
      "title": "OrFilter",
      "type": "object"
    },
    "PhraseFilter": {
      "additionalProperties": false,
      "description": "Represents a 'phrase' filter configuration in the Config schema.\n\nThis filter matches documents where a specific field contains an exact phrase.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "field": {
          "description": "The field name to apply the filter to.",
          "title": "Field",
          "type": "string"
        },
        "equals": {
          "$ref": "#/$defs/FilterScalar",
          "description": "The exact phrase value that the field must match."
        }
      },
      "required": [
        "field",
        "equals"
      ],
      "title": "PhraseFilter",
      "type": "object"
    },
    "PhrasesFilter": {
      "additionalProperties": false,
      "description": "Represents a 'phrases' filter configuration in the Config schema.\n\nThis filter matches documents where a specific field contains one or more\nof the specified phrases.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "field": {
          "description": "The field name to apply the filter to.",
          "title": "Field",
          "type": "string"
        },
        "in": {
          "description": "A list of phrases. Documents must match at least one of these phrases in the specified field.",
          "items": {
            "$ref": "#/$defs/FilterScalar"
          },
          "title": "In",
          "type": "array"
        }
      },
      "required": [
        "field",
        "in"
      ],
      "title": "PhrasesFilter",
      "type": "object"
    },
    "RangeFilter": {
      "additionalProperties": false,
      "description": "Represents a 'range' filter configuration in the Config schema.\n\nThis filter matches documents where a numeric or date field falls within a specified range.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "field": {
          "description": "The field name to apply the filter to.",
          "title": "Field",
          "type": "string"
        },
        "gte": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterScalar"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Greater than or equal to value for the range filter."
        },
        "lte": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterScalar"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Less than or equal to value for the range filter."
        },
        "lt": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterScalar"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Less than value for the range filter."
        },
        "gt": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterScalar"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Greater than value for the range filter."
        }
      },
      "required": [
        "field"
      ],
      "title": "RangeFilter",
      "type": "object"
    }
  },
  "$ref": "#/$defs/AndFilter"
}
Source code in kb_dashboard_core/filters/config.py
class AndFilter(BaseFilter):
    """Represents an 'and' filter configuration in the Config schema.

    This filter matches documents that satisfy all of the specified filters.
    """

    and_filters: list['FilterTypes'] = Field(..., alias='and')
    """A list of filters. All filters must match for a document to be included."""

Or Filter

OrFilter pydantic-model

Represents an 'or' filter configuration in the Config schema.

This filter matches documents that satisfy at least one of the specified filters.

Attributes:

Name Type Description
or_filters list[FilterTypes]

A list of filters. At least one filter must match for a document to be included.

Show JSON schema:
{
  "$defs": {
    "AndFilter": {
      "additionalProperties": false,
      "description": "Represents an 'and' filter configuration in the Config schema.\n\nThis filter matches documents that satisfy all of the specified filters.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "and": {
          "description": "A list of filters. All filters must match for a document to be included.",
          "items": {
            "$ref": "#/$defs/FilterTypes"
          },
          "title": "And",
          "type": "array"
        }
      },
      "required": [
        "and"
      ],
      "title": "AndFilter",
      "type": "object"
    },
    "CustomFilter": {
      "additionalProperties": false,
      "description": "Represents a custom filter configuration in the Config schema.\n\nThis filter allows for custom query definitions that do not fit into the standard filters.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "dsl": {
          "additionalProperties": true,
          "description": "The custom query definition. This should be a valid Elasticsearch query object.",
          "title": "Dsl",
          "type": "object"
        }
      },
      "required": [
        "dsl"
      ],
      "title": "CustomFilter",
      "type": "object"
    },
    "ExistsFilter": {
      "additionalProperties": false,
      "description": "Represents an 'exists' filter configuration in the Config schema.\n\nThis filter checks for the existence or non-existence of a specific field.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "exists": {
          "description": "The field name to check for existence. If the field exists in a document, it will match that document.",
          "title": "Exists",
          "type": "string"
        }
      },
      "required": [
        "exists"
      ],
      "title": "ExistsFilter",
      "type": "object"
    },
    "FilterScalar": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        }
      ]
    },
    "FilterTypes": {
      "oneOf": [
        {
          "$ref": "#/$defs/ExistsFilter"
        },
        {
          "$ref": "#/$defs/PhraseFilter"
        },
        {
          "$ref": "#/$defs/PhrasesFilter"
        },
        {
          "$ref": "#/$defs/RangeFilter"
        },
        {
          "$ref": "#/$defs/CustomFilter"
        },
        {
          "$ref": "#/$defs/AndFilter"
        },
        {
          "$ref": "#/$defs/OrFilter"
        },
        {
          "$ref": "#/$defs/NegateFilter"
        }
      ]
    },
    "NegateFilter": {
      "additionalProperties": false,
      "description": "Represents a negated filter configuration in the Config schema.\n\nThis allows for excluding documents that match the nested filter.\n\nNote: Unlike other filter types, NegateFilter extends BaseCfgModel directly\nrather than BaseFilter, so it does not support 'alias' or 'disabled' fields.\nThis is intentional - negation is a logical modifier that wraps another filter,\nand aliasing/disabling should be applied to the wrapped filter itself.",
      "properties": {
        "not": {
          "$ref": "#/$defs/FilterTypes",
          "description": "The filter to negate. Can be a phrase, phrases, or range filter."
        }
      },
      "required": [
        "not"
      ],
      "title": "NegateFilter",
      "type": "object"
    },
    "OrFilter": {
      "additionalProperties": false,
      "description": "Represents an 'or' filter configuration in the Config schema.\n\nThis filter matches documents that satisfy at least one of the specified filters.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "or": {
          "description": "A list of filters. At least one filter must match for a document to be included.",
          "items": {
            "$ref": "#/$defs/FilterTypes"
          },
          "title": "Or",
          "type": "array"
        }
      },
      "required": [
        "or"
      ],
      "title": "OrFilter",
      "type": "object"
    },
    "PhraseFilter": {
      "additionalProperties": false,
      "description": "Represents a 'phrase' filter configuration in the Config schema.\n\nThis filter matches documents where a specific field contains an exact phrase.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "field": {
          "description": "The field name to apply the filter to.",
          "title": "Field",
          "type": "string"
        },
        "equals": {
          "$ref": "#/$defs/FilterScalar",
          "description": "The exact phrase value that the field must match."
        }
      },
      "required": [
        "field",
        "equals"
      ],
      "title": "PhraseFilter",
      "type": "object"
    },
    "PhrasesFilter": {
      "additionalProperties": false,
      "description": "Represents a 'phrases' filter configuration in the Config schema.\n\nThis filter matches documents where a specific field contains one or more\nof the specified phrases.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "field": {
          "description": "The field name to apply the filter to.",
          "title": "Field",
          "type": "string"
        },
        "in": {
          "description": "A list of phrases. Documents must match at least one of these phrases in the specified field.",
          "items": {
            "$ref": "#/$defs/FilterScalar"
          },
          "title": "In",
          "type": "array"
        }
      },
      "required": [
        "field",
        "in"
      ],
      "title": "PhrasesFilter",
      "type": "object"
    },
    "RangeFilter": {
      "additionalProperties": false,
      "description": "Represents a 'range' filter configuration in the Config schema.\n\nThis filter matches documents where a numeric or date field falls within a specified range.",
      "properties": {
        "alias": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional alias for the filter, used for display purposes.",
          "title": "Alias"
        },
        "disabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Indicates whether the filter is disabled. If `true`, the filter will not be applied.",
          "title": "Disabled"
        },
        "field": {
          "description": "The field name to apply the filter to.",
          "title": "Field",
          "type": "string"
        },
        "gte": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterScalar"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Greater than or equal to value for the range filter."
        },
        "lte": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterScalar"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Less than or equal to value for the range filter."
        },
        "lt": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterScalar"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Less than value for the range filter."
        },
        "gt": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterScalar"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Greater than value for the range filter."
        }
      },
      "required": [
        "field"
      ],
      "title": "RangeFilter",
      "type": "object"
    }
  },
  "$ref": "#/$defs/OrFilter"
}
Source code in kb_dashboard_core/filters/config.py
class OrFilter(BaseFilter):
    """Represents an 'or' filter configuration in the Config schema.

    This filter matches documents that satisfy at least one of the specified filters.
    """

    or_filters: list['FilterTypes'] = Field(..., alias='or')
    """A list of filters. At least one filter must match for a document to be included."""