dgrdev
December 21, 2018, 12:51pm
1
hello everyone,
when I use test.rdf:
<0x1> <name> "alpha" .
<0x1> <friend> <0x2> .
<0x2> <name> "beta" .
test.schema:
friend: uid @reverse @count .
name:string @index(term, exact) .
use bulk loader:
dgraph bulk -r test.rdf -s test.schema
and I export the database and found that uid changes!!!
curl localhost:8080/admin/export
<_:uid1> <name> "alpha"^^<xs:string> .
<_:uid2711> <name> "beta"^^<xs:string> .
<_:uid1> <friend> <_:uid2711>
Could someone help me? Thanks a lot!!!
smantha
December 21, 2018, 1:13pm
2
The export data need not contain the uid you have specified.
After import you can verify that the uid are used by doing a query on an uid in ratel.
2 Likes
dgrdev
December 24, 2018, 6:30am
3
I tried to query with:
{
fd(func: eq(name,"alpha"))
{
uid
name
friend
{
uid
name
}
}
}
the result is
"data": {
"fd": [
{
"uid": "0x1",
"name": "alpha",
"friend": [
{
"uid": "0x2711",
"name": "beta"
}
]
}
]
}
“beta” uid is 0x2711, not 0x2.
dmai
(Daniel Mai)
December 24, 2018, 9:53pm
4
As @smantha said, UIDs are not preserved in the export RDF data. You can use an external ID that you control in your data if you need a persistent ID.
1 Like
dgrdev
December 25, 2018, 1:25am
5
thanks! And I also want to confirm that, dgraph live can specify UID using “assign”, but dgraph bulk cannot, right?
pablog
(Pablo Castellano)
January 12, 2020, 1:00pm
6
Just for future visits to this thread. As I understand this is not true anymore and exports now preserve UIDs. From Dgraph v1.1.0 release notes:
Export data contains UID literals instead of blank nodes. Using Live Loader or Bulk Loader to load exported data will result in the same UIDs as the original database. (#3004 , #3045 ) To preserve the previous behavior, set the --new_uids flag in the live or bulk loader. (1827787)