Support list type for language-specific string

Does the Dgraph support list type for language-specific string??

When I try to insert multiple string to the node, I found that it overwrite the previous value even if the predicate type is list type. Is there anyone the way to insert multiple language-specific strings to the the Dgraph?

My test schema and data is below:

  1. “common.topic.alias” schema
    “schema”: [ { “predicate”: “common.topic.alias”, “type”: “string”, “index”: true, “tokenizer”: [ “exact” ] } ]

  2. Test mutation query
    {
    set {
    <0x101> <common.topic.alias> “test1” .
    <0x101> <common.topic.alias> “test2” .
    <0x101> <common.topic.alias> “en-test1”@en .
    <0x101> <common.topic.alias> “en-test2”@en .
    }
    }

  3. query
    {
    q(func: uid(0x101)) {
    common.topic.alias
    }
    }

  4. query result
    {
    “data”: {
    “q”: [
    {
    “common.topic.alias”: [
    “en-test2”,
    “test1”,
    “test2”
    ]
    }
    ]
    ]

    }

Hey @hyunseok

Yes, that’s right. Only one value per language is supported even if the predicate is of list type. The way to insert multiple language specific strings would be to have a predicate dedicated to a language.

So you could have

common.topic.alias.en: [string] @index(exact) .

Then you could insert multiple values for the same language.

1 Like

Hi @pawan.

Thank you for your kind and fast reply.
I would define another predicate for multiple values of the same language.

By the way, I have another question about the above query result.
On the document of the dgraph (= https://docs.dgraph.io/query-language/#language-support),
predicate query without language tag returns an untagged string.

name => Look for an untagged string; return nothing if no untagged value exits.

But, if the predicate type is the list type, it returns all values which include @en tagged string values.

Querying for these predicates would return the list in an array.

Is there a way to get only untagged values on the dgraph??
For example, when I query to below

Query:
{
  q(func: uid(0x101)) {
      common.topic.alias
  }
}

Query Result:
{
  “data”: {
  “q”: [
    {
      “common.topic.alias”: [ 
        “test1”,
        “test2”
      ]
...

1 Like

Is there a way to get only untagged values on the dgraph??

@hyunseok there is no way to get only untagged values right now. I think we can change the behaviour to only return untagged strings for predicates of list type because there is no information right now about language in the result. Users can ask for the value in a particular language separately. Can you file an issue for this? It should be a simple change.

1 Like

Dear @pawan.
Thanks you for your kind explanation.

As you have advised, I file an issue for this to github.

I think that the dgraph is wonderful tool I never met before and the fast response is very impressed.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.