Guides v2.x

# Document Metadata

Whenever a document is created, updated or deleted, Kuzzle will add or update the document's metadata. This metadata provides information about the document's lifecycle.

You can bypass metadata automatic creation by using bulk:write or bulk:mWrite actions.

# Overview

Available since 1.3.0

Metadata can be viewed in the document's _kuzzle_info field and contains the following properties:

  • author: The unique identifier of the user who created the document.
  • createdAt: Timestamp of document creation (create or replace), in epoch-milliseconds format.
  • updatedAt: Timestamp of last document update in epoch-milliseconds format, or null if no update has been made.
  • updater: The unique identifier of the user that updated the document, or null if the document has never been updated.

Here is an example of a Kuzzle response, containing a document's _id and _source fields:

Copied to clipboard!
  "_index": "myindex",
  "_type": "mycollection",
  "_id": "AVkDLAdCsT6qHI7MxLz4",
  "_score": 0.25811607,
  "_source": {
    "message": "Hello World!",
    "_kuzzle_info": {
      "author": "<kuid>",
      "createdAt": 1481816934209,
      "updatedAt": null,
      "updater": null

# How metadata are physically stored

Documents metadata are managed by Kuzzle and cannot be changed using the API (except with bulk:write and bulk:mWrite). Metadata are stored in the _kuzzle_info field of each document in Elasticsearch.

Elasticsearch might contain documents that don't have metadata. This can be the case for documents that were not inserted through Kuzzle. Such documents will automatically obtain metadata when they are updated through Kuzzle.

# Querying Metadata

Kuzzle allows search requests to access metadata directly. This means that you'll have to search in the _kuzzle_info document property.

For example, to query by a document's creation timestamp, we can use the following search filter:

Copied to clipboard!
  "query": {
    "range": {
      "_kuzzle_info.createdAt": {
        "lte": 1481816930000