Skip to content

Metadata and versions

Your metadata

Every document can carry your own metadata: a JSON object of strings, numbers, booleans, nulls and lists of those, with at most 64 keys and 16 KB. Uploads take it as a form field; the other sources take it in the JSON body.

curl -X POST localhost:8000/api/v1/projects/1/documents \
     -F files=@policy.pdf -F metadata='{"team": "hr", "year": 2025, "tags": ["policy"]}'

Change it later. By default the new keys are merged, and null removes a key; "replace_metadata": true replaces the whole object:

curl -X PATCH localhost:8000/api/v1/projects/1/documents/7 -H 'Content-Type: application/json' \
     -d '{"metadata": {"year": 2026, "tags": null}}'

The same PATCH can change a document's external_id, and who may see it (access, see Document permissions).

Pagelore also records its own document metadata (document_metadata): the title and author found in the file, the page count, the extractor, the removed headers and footers, Docling errors, and so on.

Filters

Filter on metadata when listing documents (?metadata=<JSON>) or when retrieving (filters.metadata). A filter is a MongoDB-style object:

{"team": "hr", "year": {"$gte": 2024}, "$or": [{"tags": "policy"}, {"draft": {"$exists": false}}]}

A bare value means "equal", or "contains" for a list field.

Operator Meaning
$eq, $ne Equal, not equal
$in, $nin One of, none of a list
$gt, $gte, $lt, $lte Comparisons (numbers, strings)
$exists The key is present (true) or absent (false)
$and, $or All, or any, of a list of filters
$not The filter does not match
curl -G localhost:8000/api/v1/projects/1/documents \
     --data-urlencode 'metadata={"team": "hr", "year": {"$gte": 2024}}'

External ids and versions

Each document has an external_id, its key in the project:

Source Default external_id
Upload The file name (for a file inside an archive, archive.zip/path/in/archive)
Text The file_name
Web page The URL
S3 s3://bucket/key

Set your own (external_id on an upload or a text item) to tie a document to an id in your system.

When you send a document whose external_id the project already has:

  • Same content (same SHA-256 hash): the result is duplicate and nothing changes.
  • Other content: it becomes a new version (version 2, 3, ...). Once the new version is indexed, the older versions are deleted completely: rows, chunks, vectors and files. If indexing fails, the old version stays searchable. A new version sent without metadata keeps the old version's metadata.
sequenceDiagram
    participant App
    participant P as Pagelore
    App->>P: upload handbook.pdf (v1)
    P-->>App: indexed, version 1
    App->>P: upload handbook.pdf (changed)
    P->>P: index version 2
    P->>P: delete version 1 (rows, vectors, file)
    P-->>App: indexed, version 2, replaces [1]

on_conflict changes this:

on_conflict Behaviour
new_version The default, as above
skip Keep the old version; the result is skipped
keep_both Keep both versions, both searchable

The upload result lists the document ids it replaces, and search results show each document's version.