I'm playing with Nebula Graph 2.0.0.
I create two tags, both contain a property called name
:
create tag t1(name string)
create tag t2(name string)
Now I insert a vertex giving it t1.name
property:
> insert vertex t1(name) values '1': ('first-name');
Execution succeeded (time spent 2730/95913 us)
I can see that it can be found by ID:
> match (x:t1) where id(x) == '1' return x
+-------------------------------+
| x |
+-------------------------------+
| ("1" :t1{name: "first-name"}) |
+-------------------------------+
Got 1 rows (time spent 2713/95756 us)
I can also find it by ID and t1.name
:
> match (x:t1) where id(x) == '1' and x.name == 'first-name' return x
+-------------------------------+
| x |
+-------------------------------+
| ("1" :t1{name: "first-name"}) |
+-------------------------------+
Got 1 rows (time spent 2827/100963 us)
Now I assign t2.name
to the same vertex:
insert vertex t2(name) values '1': ('second-name');
It is added ok:
> match (x:t1) where id(x) == '1' return x
+--------------------------------------------------------+
| x |
+--------------------------------------------------------+
| ("1" :t1{name: "first-name"} :t2{name: "second-name"}) |
+--------------------------------------------------------+
Got 1 rows (time spent 3579/96685 us)
And I can still search by ID and t1.name
:
> match (x:t1) where id(x) == '1' and x.name == 'first-name' return x
+--------------------------------------------------------+
| x |
+--------------------------------------------------------+
| ("1" :t1{name: "first-name"} :t2{name: "second-name"}) |
+--------------------------------------------------------+
Got 1 rows (time spent 2534/96306 us)
But when I search by ID and t2.name
, nothing gets found:
> match (x:t1) where id(x) == '1' and x.name == 'second-name' return x
Empty set (time spent 3383/96788 us)
So, probably, under the hood, the system thinks I want to search by t1.name
, so it finds nothing.
In a different session, with tags named differently, I got a different behavior: after adding a second name
property, I lost ability to search by first name
, but it was possible to search using the second name
.
Here are my questions:
- Is it even legal to have on same vertex properties with same name (but coming from different tags)?
- If so, how can I ask the query executor to use the specific property (for instance,
t1.name
ort2.name
and not the one that the system chooses automatically)?