We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
A @lang
directive must be specified in the schema to query or mutate
predicates with language tags.
Dgraph supports UTF-8 strings.
In a query, for a string valued edge edge
, the syntax
specifies the preference order for returned languages, with the following rules.
.
means that a value without a specified language is returned or if
there is no value without language, a value in ”some” language is returned.For example:
name
=> Look for an untagged string; return nothing if no untagged value
exits.name@.
=> Look for an untagged string, then any language.name@en
=> Look for en
tagged string; return nothing if no en
tagged
string exists.name@en:.
=> Look for en
, then untagged, then any language.name@en:pl
=> Look for en
, then pl
, otherwise nothing.name@en:pl:.
=> Look for en
, then pl
, then untagged, then any language.name@*
=> Look for all the values of this predicate and return them along
with their language. For example, if there are two values with languages en
and hi, this query returns two keys named “name@en” and “name@hi”.In functions, language lists (including the @*
notation) aren’t allowed.
Untagged predicates, Single language tags, and .
notation work as described
above.
In full-text search functions (alloftext
,
anyoftext
), when no language is specified (untagged or @.
), the default
(English) full-text tokenizer is used. This does not mean that the value with
the en
tag will be searched when querying the untagged value, but that
untagged values will be treated as English text. If you don’t want that to be
the case, use the appropriate tag for the desired language, both for mutating
and querying the value.
Query Example: some of Bollywood director and actor Farhan Akhtar’s movies have a name stored in Russian as well as Hindi and English, others do not.
We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
A @lang
directive must be specified in the schema to query or mutate
predicates with language tags.
Dgraph supports UTF-8 strings.
In a query, for a string valued edge edge
, the syntax
specifies the preference order for returned languages, with the following rules.
.
means that a value without a specified language is returned or if
there is no value without language, a value in ”some” language is returned.For example:
name
=> Look for an untagged string; return nothing if no untagged value
exits.name@.
=> Look for an untagged string, then any language.name@en
=> Look for en
tagged string; return nothing if no en
tagged
string exists.name@en:.
=> Look for en
, then untagged, then any language.name@en:pl
=> Look for en
, then pl
, otherwise nothing.name@en:pl:.
=> Look for en
, then pl
, then untagged, then any language.name@*
=> Look for all the values of this predicate and return them along
with their language. For example, if there are two values with languages en
and hi, this query returns two keys named “name@en” and “name@hi”.In functions, language lists (including the @*
notation) aren’t allowed.
Untagged predicates, Single language tags, and .
notation work as described
above.
In full-text search functions (alloftext
,
anyoftext
), when no language is specified (untagged or @.
), the default
(English) full-text tokenizer is used. This does not mean that the value with
the en
tag will be searched when querying the untagged value, but that
untagged values will be treated as English text. If you don’t want that to be
the case, use the appropriate tag for the desired language, both for mutating
and querying the value.
Query Example: some of Bollywood director and actor Farhan Akhtar’s movies have a name stored in Russian as well as Hindi and English, others do not.