@lang directive ignored

Moved from GitHub pydgraph/76

Posted by jvanulde:

I am trying to add some sample data to a Dgraph instance. Here is my code thus far:

p = {}
record = { some JSON document }

p['title@en'] = record['title_translated']['en']
p['title@fr'] = "<" + str(record['title_translated']['fr']) + ">"
p['date_published'] = record['date_published']

assigned = txn.mutate(set_obj=p)

txn.commit()

I get the following error:

Error: <_Rendezvous of RPC that terminated with:
status = StatusCode.UNKNOWN
details = "Attr: [title] should have @lang directive in schema to mutate edge: [entity:1903 attr:"title" value:"Versatile Soil Moisture Budget" value_type:STRING lang:"en" ]"

I have checked the lang checkbox in the schema configuration for the title predicate. Any idea on how I can get this to work?

danielmai commented :

Can you share your schema for title?

You can do this by querying for the schema with schema(pred: [title]) {} in a query or by sharing the text output from Ratel by copying the textbox in the Bulk Edit pane.

jvanulde commented :

Every time I insert the schema gets reset in the browser. In any case I alter the schema to:

{
  "extensions": {
    "server_latency": {
      "parsing_ns": 8000,
      "processing_ns": 8500
    },
    "txn": {
      "start_ts": 879
    }
  },
  "data": {
    "schema": [
      {
        "predicate": "title",
        "type": "string",
        "index": true,
        "tokenizer": [
          "fulltext"
        ],
        "lang": true
      }
    ]
  }
}

danielmai commented :

I see "lang": true in the schema query, which means that predicate is set with the @lang directive to support language strings.

Every time I insert the schema gets reset in the browser.

Dgraph won’t automatically reset the schema unless you send an operation to do so. Is DropAll being run somewhere else, perhaps in some test setup functions?

mangalaman93 commented :

Closing due to inactivity