{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gxplex.com/api/v1/schema/concordance-occurrences.json",
  "title": "Occurrences of the exact-term index in one tracked row document",
  "description": "The document served at /api/v1/concordance-occurrences.json. Items are carried under `items`.",
  "type": "object",
  "allOf": [
    {
      "$ref": "https://gxplex.com/api/v1/schema/envelope.json"
    }
  ],
  "properties": {
    "collection": {
      "const": "concordance-occurrences"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      },
      "description": "Every occurrences of the exact-term index in one tracked row this document carries."
    }
  },
  "required": [
    "items"
  ],
  "additionalProperties": true,
  "$defs": {
    "item": {
      "type": "object",
      "title": "Occurrences of the exact-term index in one tracked row",
      "description": "One tracked row, with every occurrence of a term of the exact-term index in its current text where that text is read, each in context and with its clause anchor, and every occurrence in its title as this record holds it. The derivation, its rules and its version ride in the envelope under `derivation`.",
      "properties": {
        "licence_class": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "open",
            "restricted",
            "unknown",
            null
          ],
          "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."
        },
        "source": {
          "type": "object",
          "description": "The tracked entry this object is about, its state, and where it resolves on this site. `state` is one of `tracked` (this record holds the entry), `not-tracked` (an id is named and this record holds no entry under it) or `no-subject` (the object names no entry, so no lookup applies). `resolves_to` carries an address only where the state is `tracked`; a minted address for an untracked id would 404, and a consumer cannot tell a 404 from a deploy that dropped a file."
        },
        "observed_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "The day THIS RECORD observed the fact this object carries, at day granularity. It is never a publisher's own date for an event and never a build clock. Null where no such day was read."
        },
        "observed_at_state": {
          "type": "string",
          "enum": [
            "recorded",
            "not-carried",
            "not-an-observation"
          ],
          "description": "Which of the two absences a null `observed_at` is. `not-carried`: this object is a record about something observable and carries no day for when this record read it. `not-an-observation`: this object is not a record of a retrieval at all — a corpus summary, a coverage term — so no day is missing from it. Opposite facts, one blank."
        },
        "observed_at_read_from": {
          "type": [
            "string",
            "null"
          ],
          "description": "The key on the emitting store `observed_at` was read from, so the value can be checked against the store rather than trusted. Null only where the state is `not-an-observation`, which is the one case with no field to name."
        },
        "distance": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "description": "Distance from the source on the filed scale — 0 primary, 1 official notice, 2 official related record, 3 third-party. Defined for signals only. Null on every other object, and a null is NOT zero: zero is the strongest claim the scale makes."
        },
        "distance_label": {
          "type": [
            "string",
            "null"
          ],
          "description": "The scale's own word for `distance`, read from the one home that holds the scale. Null where no distance was read, and null where the record's own label disagrees with the scale — a disagreement is withheld rather than reconciled, because neither side adjudicates the other."
        },
        "distance_state": {
          "type": "string",
          "enum": [
            "recorded",
            "unmeasured",
            "field-absent",
            "out-of-scale",
            "label-disagrees",
            "not-a-signal"
          ],
          "description": "Which reading produced `distance`. `not-a-signal`: this object has no position on the scale. `field-absent`: the record carries no distance key. `unmeasured`: the key is present and null — the entry declared no address to measure from. `out-of-scale`: the record's value is not a member of the scale, so no value is published. `label-disagrees`: the value IS a member and the record's own label is not the scale's word for it, so the value is published and the LABEL is withheld — the two are different withholdings and one sentence covering both said the value was withheld in a case where it is served."
        },
        "instrument_id": {
          "type": "string",
          "description": "The tracked row."
        },
        "url": {
          "type": "string",
          "description": "The row's permanent address on this site, which resolves to its page."
        },
        "jurisdiction": {
          "type": "string",
          "description": "The row's jurisdiction, as the tracker serves it."
        },
        "class": {
          "type": [
            "string",
            "null"
          ],
          "description": "The value the tracker's \"Class (as stated)\" filter carries for the row. Null where that filter reads \"title states no class\"."
        },
        "status": {
          "type": "string",
          "description": "The row's recorded status, as the tracker serves it."
        },
        "content_hash": {
          "type": [
            "string",
            "null"
          ],
          "description": "The digest of the row's current text: the newest observation that records one. Null where no observation records one."
        },
        "first_observed": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "The day of the first observation that recorded `content_hash`. Null where the store holds no line for it."
        },
        "text_state": {
          "type": "string",
          "enum": [
            "read",
            "refused",
            "no text observed",
            "not derived under this version"
          ],
          "description": "The envelope's `text_states_mean` states each value."
        },
        "why": {
          "type": [
            "string",
            "null"
          ],
          "description": "The condition a refused text failed, as the clause-anchor store holds it. Null otherwise."
        },
        "derivation_version": {
          "type": [
            "string",
            "null"
          ],
          "description": "The version of the derivation that wrote the line served. Null where none was written."
        },
        "occurrences": {
          "type": "array",
          "items": {
            "type": "object"
          },
          "description": "One per occurrence in the current text, in the order of the index's terms and then of offset: `term`; `at`; `quote_at` and `quote` (the context, as the envelope's `context_rule` states it, or null with `quote_withheld` giving the reason); `anchor` (a clause anchor id, or null); `anchor_state` (the envelope's `anchor_states_mean` states each value); and `anchor_withheld` (the clause-anchor rules' reason where the heading before it is withheld, else null). Empty where the text is not read."
        },
        "occurrence_count": {
          "type": "integer",
          "description": "The length of `occurrences`."
        },
        "title_occurrences": {
          "type": "array",
          "items": {
            "type": "object"
          },
          "description": "One per occurrence in the row's title as this record holds it, for every row: `term`, `at` (code points into the title), `title` (the title whole, or null where it is longer than the quote cap) and `title_withheld` (the reason it is null, else null)."
        },
        "title_occurrence_count": {
          "type": "integer",
          "description": "The length of `title_occurrences`."
        },
        "earlier_texts": {
          "type": "array",
          "items": {
            "type": "object"
          },
          "description": "Every other text of the row the store holds a line for under the current version, oldest first: `content_hash`, `first_observed`, `text_state` and `occurrence_count`. Its occurrences are held in the store and not served here."
        }
      },
      "required": [
        "instrument_id",
        "url",
        "jurisdiction",
        "class",
        "status",
        "content_hash",
        "first_observed",
        "text_state",
        "why",
        "derivation_version",
        "occurrences",
        "occurrence_count",
        "title_occurrences",
        "title_occurrence_count",
        "earlier_texts",
        "licence_class",
        "text_retained",
        "quote_allowed",
        "snapshot_available",
        "rights_of",
        "source",
        "observed_at",
        "observed_at_state",
        "observed_at_read_from",
        "distance",
        "distance_label",
        "distance_state"
      ],
      "additionalProperties": true
    }
  }
}
