Import errors: Attr should have @lang directive in schema to mutate edge

I’m trying to import the Brick (https://brickschema.org) schema into DGraph using “dgraph live”, having converted the Turtle files to n-quads via rapper, but every tuple with a literal with a language tag throws and error like:

Error while mutating Attr: [http://www.w3.org/2000/01/rdf-schema#label] should have @lang directive in schema to mutate edge: [entity:2470046 attr:"http://www.w3.org/2000/01/rdf-schema#label" value:"Speed" lang:"en" ]

Tuples look like:

<https://brickschema.org/schema/1.0.2/Brick#Speed> <http://www.w3.org/2000/01/rdf-schema#label> "Speed"@en .

I apologize for the newbie question, but this whole domain is new to me.

You should set the schema for the predicate <http://www.w3.org/2000/01/rdf-schema#label> to be language strings.

<http://www.w3.org/2000/01/rdf-schema#label>: string @lang .

https://docs.dgraph.io/query-language/#language-support

If you’re trying out Dgraph for the first time, well, welcome! You can check out the Tour of Dgraph to familiarize yourself with Dgraph. https://tour.dgraph.io/

Thanks for the very fast response.

Yes, I am well past the tour and am now trying to do something “useful” with building data as a PoC.

So. there are many predicates, with several difference namespaces, using languages tags, but no schema settings for them. I suspect that this question is kind of specific to the Brick schema I’m trying to load, but in general, could you says whether would these all be defined in one’s import file up front? Or is there likely a “base” schema file (for http://www.w3.org/2000/01/rdf-schema) somewhere that I should have loaded first or something like that?

This whole business of RDF schemas and graph databases certainly involves a learning curve :slight_smile:

Dgraph has its own schema where you can specify the types and indices for each predicate in Dgraph.

The schema can be set up-front as a file you pass to the live loader. e.g., the schema file can look like this (say, in a file named schema.txt):

<predicate1>: string @lang .
<predicate2>: string @lang .
<predicate3>: string @lang .

Then you can pass this to live loader with the -s flag:

dgraph live -r data.rdf.gz -s schema.txt

More about the format of making schema changes is in the docs: https://docs.dgraph.io/query-language/#adding-or-modifying-schema

1 Like

Nice. Thanks, I was wondering about the -s flag.

The full docs for the Dgraph Live Loader are here: https://docs.dgraph.io/deploy/#fast-data-loading

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