How to address a node after bulk import?


#1

Hi!
Let’s say I have such rdf dataset:

|<http://rdf.freebase.com/ns/m.056sql>|<http://rdf.freebase.com/ns/type.object.key>|"/wikipedia/zh-cn_id/1268772"|.|
|---|---|---|---|
|<http://rdf.freebase.com/ns/m.056sql>|<http://rdf.freebase.com/ns/location.location.containedby>|<http://rdf.freebase.com/ns/m.0p2n>|.|
|<http://rdf.freebase.com/ns/m.056sql>|<http://rdf.freebase.com/ns/location.location.containedby>|<http://rdf.freebase.com/ns/m.0jgd>|.|
|<http://rdf.freebase.com/ns/m.056sql>|<http://rdf.freebase.com/ns/type.object.key>|"/wikipedia/zh-cn_title/$63D0$5E15$65AF$706B$5C71"|.|
|<http://rdf.freebase.com/ns/m.056sql>|<http://rdf.freebase.com/key/wikipedia.uk>|"Walther_Penck"|.|
|<http://rdf.freebase.com/ns/m.056sql>|<http://rdf.freebase.com/ns/type.object.key>|"/wikipedia/uk/$0412$043E$043B$044C$0442$0435$0440-$041F$0435$043D$043A"|.|
|<http://rdf.freebase.com/ns/m.056sql>|<http://rdf.freebase.com/ns/type.object.name>|"提帕斯火山"@zh|.|

Then I import a dataset with such schema:

<http://rdf.freebase.com/ns/type.object.name>: string @lang .

How can I query this node <http://rdf.freebase.com/ns/m.056sql> without knowing it uid (I mean how can I reference exactly this node in the query)? Can I use m.056sql somehow? May be there are ways to find out it’s uid?

Thanks in advance


(Michel Conrado) #2

You should index those nodes.

<http://rdf.freebase.com/ns/type.object.name>: string @index(hash) @lang .
{
  q(func: eq(<http://rdf.freebase.com/ns/type.object.name>@zh, "提帕斯火山")) {
    uid
    <http://rdf.freebase.com/ns/type.object.name>
    <http://rdf.freebase.com/ns/type.object.key>
   #add others edges here
  }
}

#3

So am I right, that I can’t make use of this id m.056sql? Can I update the schema somehow, so m.056sql becomes a named field (freebase_id for example)? If I can - will it still work if I use bulk?


(Michel Conrado) #4

yep, the triple pattern does not allow you to use the first field as a real identifier. Just an intermediate identifier. That is, the <subject> will be replaced by the UID when the mutation is performed.

https://docs.dgraph.io/mutations/#blank-nodes-and-uid
https://tour.dgraph.io/intro/5/

In theory yes, in practice you will have to edit your dataset. In all data, you must add a field for the new identifier.

Also you could check this pritice https://docs.dgraph.io/mutations/#external-ids and https://docs.dgraph.io/mutations/#external-ids-and-upsert-block