Skip to main content

String

string holds text.

ValueExample
any JSON string"Berlin"

Settings

SettingMeaning
maxLengthThe maximum number of characters, checked on every write. It is not part of the mappings of the databases. Optional, no limit by default.
enumThe allowed values, a non-empty list of distinct strings, e.g. ["draft", "published"]. Values are compared exactly, also by case. Optional, every string is allowed by default. See enums.

The settings of every property apply as well. A raw Elasticsearch or raw Neo4j index can replace the generic mapping.

Storage

DatabaseStored asNotes
Neo4jnative STRING(default up to 1024 characters)
MongoDBstring(default above 1024 characters), shorter strings with "storage": "document" or the placement role scalar moved to MongoDB
Elasticsearchtext with a keyword sub-field, keyword for enums (the mapping depends on the index)search copy, see below

The search copy is written unless the property or the type sets "search": false. Where a property is stored is explained in placement.

Enums

A string with enum only accepts the listed values, on every write and in lists ("items": {"type": "string", "enum": [...]}). Use it for values which are known when the schema is written, e.g. a status; for open sets of values, e.g. tags, use a plain string with an exact index instead. MongoDB validates the values of nested enums as well, and the search copy maps enums as keyword, as their values are identifiers, not text.

Changing the list does not change existing elements: an element keeps a value which was removed from the list, until the property is written again. Writing the old value is rejected.

{
"type": "string",
"enum": [
"draft",
"published",
"archived"
],
"index": "exact"
}

Indices

exact and fulltext, also both together, see indices. Nested properties can be indexed as well, see nested properties.

Limits

Without maxLength the length is only limited by the request size and the databases. Strings of more than 1024 characters are stored in MongoDB unless the property sets a storage, as long strings slow down Neo4j. The keyword sub-field of Elasticsearch ignores strings of more than 256 characters, they are still found by the text field.

Example

Schema:

{
"type": "string",
"maxLength": 64,
"index": [
"exact",
"fulltext"
]
}

Input and output:

{
"data": {
"value": "Berlin"
}
}