{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/standards-new/json-schema/standards-new-search-query-dto-schema.json",
  "title": "SearchQueryDto",
  "description": "Full-text search query with the same filtering options as list.",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/standards-new-openapi.json#/components/schemas/SearchQueryDto",
  "type": "object",
  "properties": {
    "q": {
      "type": "string",
      "description": "Full-text search query."
    },
    "limit": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100,
      "default": 20,
      "description": "Page size. Values above 100 are clamped to 100."
    },
    "offset": {
      "type": "integer",
      "minimum": 0,
      "default": 0,
      "description": "Number of records to skip."
    },
    "countMode": {
      "type": "string",
      "enum": [
        "none",
        "estimated",
        "exact"
      ],
      "default": "estimated",
      "description": "Total-count strategy for the response."
    },
    "sorts": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SortRule"
      },
      "description": "Sort rules, applied in order."
    },
    "filters": {
      "$ref": "#/$defs/FilterState"
    },
    "relationScope": {
      "type": "object",
      "properties": {
        "objectName": {
          "type": "string"
        },
        "recordId": {
          "type": "string"
        },
        "attribute": {
          "type": "string"
        }
      },
      "required": [
        "objectName",
        "recordId",
        "attribute"
      ],
      "description": "Scope the collection through a relation attribute on its owner record."
    },
    "group": {
      "type": "object",
      "properties": {
        "attribute": {
          "type": "string"
        },
        "value": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "attribute",
        "value"
      ],
      "description": "Select one Kanban partition, combined with the complete filter predicates."
    },
    "userFilters": {
      "$ref": "#/$defs/FilterState"
    },
    "visibility": {
      "type": "string",
      "enum": [
        "workspace",
        "private"
      ],
      "description": "Narrow the result to a record visibility scope without widening access."
    },
    "timezone": {
      "type": "string",
      "description": "IANA timezone for resolving @today dynamic filter values."
    },
    "fields": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Attribute names to hydrate from reference edges. Omitted → all reference attributes are hydrated. An empty array disables reference hydration entirely (reference keys are absent from the response). Unknown names are ignored."
    }
  },
  "required": [
    "q"
  ],
  "$defs": {
    "FilterRule": {
      "type": "object",
      "description": "A single filter rule. The operator must be valid for the attribute's type.",
      "properties": {
        "attribute": {
          "type": "string",
          "description": "Root attribute name (a scalar attribute, or a reference attribute when `property` is set)."
        },
        "property": {
          "type": "string",
          "description": "When set, the rule filters on a qualified edge property of a reference attribute (relation or document). The operator then applies to the property's type."
        },
        "quantifier": {
          "type": "string",
          "enum": [
            "any",
            "none"
          ],
          "description": "Existence quantifier for qualified edge rules (\"at least one\" vs \"none\"). Only valid when `property` is set; defaults to the operator-derived polarity."
        },
        "operator": {
          "type": "string",
          "enum": [
            "is",
            "is_not",
            "contains",
            "not_contains",
            "starts_with",
            "ends_with",
            "less_than",
            "greater_than",
            "less_or_equal",
            "greater_or_equal",
            "is_within",
            "on_day_month",
            "any_of",
            "none_of",
            "is_empty",
            "is_not_empty"
          ],
          "description": "Filter operator. The valid subset depends on the attribute type (text, number, checkbox, date, select, multiselect, relation). The ordering operators (`less_than`, `greater_than`, `less_or_equal`, `greater_or_equal`) also apply to text, `label` and `id`: text compares by code point, and an `id` range is bounded by a whole UUID. Short codes (`lt`, `gte`, `eq`, `in`, …) are accepted and normalized."
        },
        "value": {
          "description": "Filter value. The type depends on the attribute and operator: string, number, boolean, array of strings, a relative date object ({ amount, unit, direction }) for `is_within`, a dynamic value such as @me ({ dynamic: \"actor\", ref: \"current\" }) or @today ({ dynamic: \"date\", anchor: \"today\" }), or null for operators like `is_empty`."
        }
      },
      "required": [
        "attribute",
        "operator",
        "value"
      ]
    },
    "FilterState": {
      "type": "object",
      "description": "Filter configuration: a combinator plus a flat list of rules.",
      "properties": {
        "combinator": {
          "type": "string",
          "enum": [
            "and",
            "or"
          ],
          "description": "How to combine rules."
        },
        "rules": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/FilterRule"
          }
        }
      },
      "required": [
        "combinator",
        "rules"
      ]
    },
    "SortRule": {
      "type": "object",
      "description": "A single sort rule.",
      "properties": {
        "attribute": {
          "type": "string",
          "description": "Attribute name to sort by."
        },
        "direction": {
          "type": "string",
          "enum": [
            "asc",
            "desc"
          ],
          "description": "Sort direction."
        }
      },
      "required": [
        "attribute",
        "direction"
      ]
    }
  }
}