# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

namespace=document.config

## Whether attempts to set an undefined field should be ignored rather than causing an error
ignoreundefinedfields bool default=false

## Prefer "Vespa 8" format for the "position" type
usev8geopositions bool default=false

## The Id of the datatype. Must be unique, including not
## overlapping with the internal datatypes (defined in datatype.h)
datatype[].id int

## Use if this datatype is an array type, for instance an int
## or double array. Specifies the datatype we have an array of.
## This can be a built-in datatype or a new one created here, meaning
## that for instance arrays of arrays are allowed.
datatype[].arraytype[].datatype int

## Map type. Keys and values can be built in types or types created here.
datatype[].maptype[].keytype int
datatype[].maptype[].valtype int

## Use if this datatype is a weighted set type, for instance an int
## or double weighted set. Specifies the datatype we have a weighted set of.
## This can be a built-in datatype or a new one craeted here, meaning
## that for instance weighted sets of weighted sets are allowed.
datatype[].weightedsettype[].datatype int

## Should an update to a nonexistant element cause it to be created
datatype[].weightedsettype[].createifnonexistant bool default=false

## Should an element in a weighted set be removed if an update changes the weight to 0
datatype[].weightedsettype[].removeifzero bool default=false

## Specify the name of the document type. Must be unique.
datatype[].structtype[].name string

## Verison is not in use
datatype[].structtype[].version int default=0

## Specify which compression to use if compression is enabled above
datatype[].structtype[].compresstype enum { NONE, UNCOMPRESSABLE, LZ4 } default=NONE

## Specify the compression level to use if compression is enabled
datatype[].structtype[].compresslevel int default=0

## Specify the minimum reduction required from compression in order to keep the compressed version (maximum percentage of original size)
datatype[].structtype[].compressthreshold int default=95

## Specify the minimum size of the struct data before we even try to compress it
datatype[].structtype[].compressminsize int default=800

## Specify a document field name. Must be unique within the document type.
datatype[].structtype[].field[].name string

## Specify a document field id. If not specified, this is generated by a hash function
datatype[].structtype[].field[].id[].id int

## Specify the datatype of the field. Can be a built-in datatype or
## one specified in config.
datatype[].structtype[].field[].datatype int

## Additional, optional type information which can be changed without
## (necessarily) causing field incompatibility
datatype[].structtype[].field[].detailedtype string default=""

## Specify a struct type to inherit
datatype[].structtype[].inherits[].name string

## Version is not in use
datatype[].structtype[].inherits[].version int default=0

## Specity an annotation reference type and the name of the annotation type it is referencing
datatype[].annotationreftype[].annotation string

## Specify the name of the document type. Must be unique.
datatype[].documenttype[].name string

## Version is not in use
datatype[].documenttype[].version int default=0

## Specify a document type to inherit
datatype[].documenttype[].inherits[].name string

## Version is not in use
datatype[].documenttype[].inherits[].version int default=0

## Name of header struct defining document header.
datatype[].documenttype[].headerstruct int

## Specify a document field id. Must be unique within the document type.
datatype[].documenttype[].bodystruct int default=0

## Field sets
datatype[].documenttype[].fieldsets{}.fields[] string

## Imported fields (specified outside the document block in the schema)
datatype[].documenttype[].importedfield[].name string

## Cross-document reference with ID of target document type
datatype[].referencetype[].target_type_id int

## The Id of the annotation type. Must be unique.
annotationtype[].id int
annotationtype[].name string
annotationtype[].datatype int default=-1
annotationtype[].inherits[].id int


# Here starts a new model for how datatypes are configured, where
# everything is per document-type, and each documenttype contains the
# datatypes it defines.  Will be used (only?) if the arrays above
# (datatype[] and annotationtype[]) are empty.


# Note: we will include the built-in "document" document
# type that all other doctypes inherit from also, in order
# to get all the primitive and built-in types declared
# with an idx we can refer to.

## Name of the document type. Must be unique.
doctype[].name string

# Note: indexes are only meaningful as internal references in this
# config; they will typically be sequential (1,2,3,...)  in the order
# that they are generated (but nothing should depend on that).

## Index of this type (as a datatype which can be referred to).
doctype[].idx int

# Could also use name here?
## Specify document types to inherit
doctype[].inherits[].idx int

## Index of struct defining document fields
doctype[].contentstruct int

## Field sets available for this document type
doctype[].fieldsets{}.fields[] string

## Imported fields (specified outside the document block in the schema)
doctype[].importedfield[].name string

# Everything below here is configuration of data types defined by
# this document type.

# Primitive types must be present as built-in static members.

## Index of primitive type
doctype[].primitivetype[].idx int

## The name of this primitive type
doctype[].primitivetype[].name string

# Arrays are the simplest collection type:

## Index of this array type
doctype[].arraytype[].idx int

## Index of the element type this array type contains
doctype[].arraytype[].elementtype int


# Maps are another collection type:

## Index of this map type
doctype[].maptype[].idx int

## Index of the key type used by this map type
doctype[].maptype[].keytype int

## Index of the key type used by this map type
doctype[].maptype[].valuetype int


# Weighted sets are more complicated;
# they can be considered as an collection
# of unique elements where each element has
# an associated weight:

## Index of this weighted set type
doctype[].wsettype[].idx int

## Index of the element types contained in this weighted set type
doctype[].wsettype[].elementtype int

## Should an update to a nonexistent element cause it to be created 
doctype[].wsettype[].createifnonexistent bool default=false

## Should an element in a weighted set be removed if an update changes the weight to 0
doctype[].wsettype[].removeifzero bool default=false


# Tensors have their own type system

## Index of this tensor type
doctype[].tensortype[].idx int

## Description of the type of the actual tensors contained
doctype[].tensortype[].detailedtype string


# Document references refer to parent documents that a document can
# import fields from:

## Index of this reference data type:
doctype[].documentref[].idx int

# Could also use name?
## Index of the document type this reference type refers to:
doctype[].documentref[].targettype int


# Annotation types are another world, but are modeled here
# as if they were also datatypes contained inside document types:

## Index of an annotation type.
doctype[].annotationtype[].idx int

## Name of the annotation type.
doctype[].annotationtype[].name string

# Could we somehow avoid this?
## Internal id of this annotation type
doctype[].annotationtype[].internalid int default=-1

## Index of contained datatype of the annotation type, if any
doctype[].annotationtype[].datatype int default=-1

## Index of annotation type that this type inherits.
doctype[].annotationtype[].inherits[].idx int


# Annotation references are field values referring to
# an annotation of a certain annotation type.

## Index of this annotation reference type
doctype[].annotationref[].idx int

## Index of the annotation type this annotation reference type refers to
doctype[].annotationref[].annotationtype int


# A struct is just a named collections of fields:

## Index of this struct type
doctype[].structtype[].idx int

## Name of the struct type. Must be unique within documenttype.
doctype[].structtype[].name string

## Index of another struct type to inherit
doctype[].structtype[].inherits[].type int

## Name of a struct field. Must be unique within the struct type.
doctype[].structtype[].field[].name string

## The "field id" - used in serialized format!
doctype[].structtype[].field[].internalid int

## Index of the type of this field
doctype[].structtype[].field[].type int

