{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gxplex.com/api/v1/schema/concordance.json",
  "title": "Concordance entry document",
  "description": "The document served at /api/v1/concordance.json. Items are carried under `items`.",
  "type": "object",
  "allOf": [
    {
      "$ref": "https://gxplex.com/api/v1/schema/envelope.json"
    }
  ],
  "properties": {
    "collection": {
      "const": "concordance"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      },
      "description": "Every concordance entry this document carries."
    }
  },
  "required": [
    "items"
  ],
  "additionalProperties": true,
  "$defs": {
    "item": {
      "type": "object",
      "title": "Concordance entry",
      "description": "A run of exact words and the tracked entries it was indexed for. Each citation carries, as exact_words, whether the text read for that entry holds those words exactly, does not hold them, or is not measured; notice states what the entry claims on that reading. Nothing else is stated.",
      "properties": {
        "id": {
          "type": "string",
          "description": "The identifier of this entry."
        },
        "topic": {
          "type": "string",
          "description": "The exact words, as matched: letter for letter in the same case, no plural and no other ending."
        },
        "citations": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "licence_class": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "open",
                  "restricted",
                  "unknown"
                ],
                "description": "What this archive recorded of the terms the source states. Null where no reading exists for this object. See `rights` on the envelope."
              },
              "text_retained": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Whether normalised prose of the document is held here for a quotation to be checked against. Held, never served. Null where no reading exists."
              },
              "quote_allowed": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Whether a quotation from the document appears in this record's own published output. A fact about this record's handling, not a reading of what the publisher permits, and not a grant. Null where no reading exists."
              },
              "snapshot_available": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Whether a retained snapshot of an observed retrieval is still held here for a digest to be re-checked against. No snapshot is served. Null where no reading exists."
              },
              "rights_of": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The tracked entry id the four fields above are the rights OF. Null where the object names no entry."
              },
              "rights_unresolved": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Present only where the four fields are null, naming which absence it is: an id this record does not hold, or an object that names no entry."
              }
            },
            "additionalProperties": true
          },
          "description": "Two or more entries of instrument_id, section, source_url and exact_words — what this build read for the entry: holds, absent or unmeasured, the count, and the address and day the text was retained from. quote and term_form appear only for openly licensed text and only where the recorded span holds the exact words in the text read; otherwise quote_withheld states why. Each carries the four rights fields of the entry it cites."
        },
        "notice": {
          "type": "string",
          "description": "What this entry states on the reading of this build: \"These exact words occur in these sources.\" where every listing holds the words, and otherwise how many do, how many do not, and how many are not measured."
        }
      },
      "required": [
        "id",
        "topic",
        "citations"
      ],
      "additionalProperties": true
    }
  }
}
