Skip to content

Commit e838bd9

Browse files
authored
Documentation on IRI predicates and facets (#2792)
* added i18n docs in schema section. * added predicate i18n section. added facets i18n section.
1 parent 290028d commit e838bd9

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

wiki/content/query-language/index.md

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,9 +1997,48 @@ If data exists and new indices are specified in a schema mutation, any index not
19971997

19981998
Reverse edges are also computed if specified by a schema mutation.
19991999

2000-
{{% notice "note" %}} If your predicate is a URI or has special characters, then you should wrap
2001-
it with angular brackets while doing the schema mutation. E.g. `<first:name>`{{% /notice %}}
2000+
### Predicates i18n
20022001

2002+
If your predicate is a URI or has laguange-specific vocabs, then enclose
2003+
it with angle brackets `<>` when executing the schema mutation.
2004+
2005+
{{% notice "note" %}}Dgraph supports [Internationalized Resource Identifier](https://en.wikipedia.org/wiki/Internationalized_Resource_Identifier) (IRI) for predicate names and values.{{% /notice %}}
2006+
2007+
Schema syntax:
2008+
```
2009+
<职业>: string @index(exact) .
2010+
<年龄>: int @index(int) .
2011+
<地点>: geo @index(geo) .
2012+
<公司>: string .
2013+
```
2014+
2015+
This syntax allows for internationalized predicate, but fulltext indexing still defaults to English.
2016+
To use the right tokenizer for your language, you need to use the `@lang` directive and enter values using your
2017+
language tag.
2018+
2019+
Schema:
2020+
```
2021+
<公司>: string @index(fulltext) @lang .
2022+
```
2023+
Mutation:
2024+
```
2025+
{
2026+
set {
2027+
_:a <公司> "Dgraph Labs Inc"@en
2028+
_:b <公司> "夏新科技有限责任公司"@zh
2029+
}
2030+
}
2031+
```
2032+
Query:
2033+
```
2034+
{
2035+
query {
2036+
q (func: alloftext(<公司>@., <夏新科技有限责任公司>)) {
2037+
_predicate_
2038+
}
2039+
}
2040+
}
2041+
```
20032042

20042043
### Upsert directive
20052044

@@ -2344,6 +2383,30 @@ All facets on an edge are queried with `@facets`.
23442383
}
23452384
{{</ runnable >}}
23462385

2386+
### Facets i18n
2387+
2388+
Facets keys and values can use language vocabs directly when mutating. But facet keys need to be enclosed in angle brackets `<>` when querying. This is similar to predicates. See [Predicates i18n](#predicates-i18n) for more info.
2389+
2390+
{{% notice "note" %}}Dgraph supports [Internationalized Resource Identifier](https://en.wikipedia.org/wiki/Internationalized_Resource_Identifier) (IRI) for facet keys when querying.{{% /notice %}}
2391+
2392+
Example:
2393+
```
2394+
{
2395+
set {
2396+
_:person1 <name> "Daniel" (वंश="स्पेनी", ancestry="Español") .
2397+
_:person2 <name> "Raj" (वंश="हिंदी", ancestry="हिंदी") .
2398+
_:person3 <name> "Zhang Wei" (वंश="चीनी", ancestry="中文") .
2399+
}
2400+
}
2401+
```
2402+
Query, notice the `<>`'s:
2403+
```
2404+
{
2405+
q (func: has(name)) {
2406+
name @facets(<वंश>)
2407+
}
2408+
}
2409+
```
23472410

23482411
### Alias with facets
23492412

0 commit comments

Comments
 (0)