String
string holds text.
| Value | Example |
|---|---|
| any JSON string | "Berlin" |
Settings
The settings of every apply as well. A raw or raw index can replace the generic mapping.
Storage
| Database | Stored as | Notes |
|---|---|---|
| Neo4j | native STRING | (default up to 1024 characters) |
| MongoDB | string | (default above 1024 characters), shorter strings with "storage": "document" or the placement scalar moved to MongoDB |
| Elasticsearch | text with a keyword sub-field, keyword for enums (the mapping depends on the ) | search copy, see below |
The search is written unless the property or the type sets "search": false. Where a property is stored is explained in .
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 . Nested properties can be indexed as well, see nested .
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" }}