food
node. The node representing a review comment as a review
node, and the
node representing the country of origin as a country
node.
Here’s the relationship between them:
review
edge.origin
edge.Sushi
in more than one
language. We’ll be writing the review in three different languages: English,
Japanese, and Russian.
Here’s the mutation to do so.
comment
predicate
in different languages.
We used the language tags (@ru, @jp) as a suffix for the comment
predicate.
In the above mutation:
@ru
language tag to add the comment in Russian:
"comment@ru": "очень вкусно"
.
@jp
language tag to add the comment in Japanese:
"comment@jp": "とても美味しい"
.
English
is untagged: "comment": "Tastes very good"
.
comment
, comment@ru
, and comment@jp
in different predicates inside the
same node.
Note: If you’re not clear about basic terminology like predicates
, do read
the first tutorial.
Let’s run the above mutation.
Go to the mutate tab, paste the mutation, and click Run.
@lang
directive to the schema.
Follow the instructions below to add the @lang
directive to the comment
predicate.
comment
predicate.lang
directive.Update
button.Sushi
.
In the previous article, we learned about using the
eq
operator and the hash
index to query for string predicate values.
Using that knowledge, let’s first add the hash
index for the food_name
predicate.
Sushi
in Japanese.
Sushi
in Russian.
Sushi
written in any language.
Syntax | Result |
---|---|
comment | Look for an untagged string; return nothing if no untagged review exists. |
comment@. | Look for an untagged string, if not found, then return review in any language. But, this returns only a single value. |
comment@jp | Look for comment tagged @jp . If not found, the query returns nothing. |
comment@ru | Look for comment tagged @ru . If not found, the query returns nothing. |
comment@jp:. | Look for comment tagged @jp first. If not found, then find the untagged comment. If that’s not found too, return anyone comment in other languages. |
comment@jp:ru | Look for comment tagged @jp , then @ru . If neither is found, it returns nothing. |
comment@jp:ru:. | Look for comment tagged @jp , then @ru . If both not found, then find the untagged comment. If that’s not found too, return any other comment if it exists. |
comment@* | Return all the language tags, including the untagged. |
Borscht
with its review
in Russian
.
@ru
for the review written in
Russian.
Hence, if we query for all the reviews written in Russian
, the review for
Borscht
doesn’t make it to the list.
Only the review for Sushi,
written in Russian
, makes it to the list.
If you are representing the same information in different languages, don’t forget to add your language tags!