{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://fdc3.finos.org/schemas/next/context/chatSearchCriteria.schema.json",
  "type": "object",
  "title": "ChatSearchCriteria",
  "description": "A context type that represents a simple search criterion, based on a list of other context objects, that can be used to search or filter messages in a chat application.",
  "allOf": [
    {
      "type": "object",
      "properties": {
        "type": {
          "const": "fdc3.chat.searchCriteria"
        },
        "criteria": {
          "title": "Search Criteria array",
          "description": "An array of criteria that should match chats returned from by a search.\n\n⚠️ Operators (and/or/not) are not defined in `fdc3.chat.searchCriteria`. It is up to the application that processes the FDC3 Intent to choose and apply the operators between the criteria.\n\nEmpty search criteria can be supported to allow resetting of filters.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/SearchCriteria"
          }
        }
      },
      "required": [
        "criteria"
      ]
    },
    { "$ref": "context.schema.json#/definitions/BaseContext" }
  ],
  "$defs": {
    "SearchCriteria": {
      "title": "Search Criteria",
      "description": "An individual criteria against which to match chat messages, based on an FDC3 context or free-text string.",
      "oneOf": [
        {
          "$ref": "instrument.schema.json#"
        },
        {
          "$ref": "organization.schema.json#"
        },
        {
          "$ref": "contact.schema.json#"
        },
        {
          "type": "string",
          "title": "Free text",
          "description": "Free text to be used for a keyword search"
        }
      ]
    }
  },
  "examples": [
    {
      "type": "fdc3.chat.searchCriteria",
      "criteria": [
        {
          "type": "fdc3.contact",
          "name": "Jane Doe",
          "id": {
            "email": "jane.doe@mail.com"
          }
        },
        {
          "type": "fdc3.instrument",
          "id": {
            "ticker": "TSLA"
          },
          "name": "Tesla, inc."
        },
        "annual return"
      ]
    }
  ]
}