Star

给点设定多TAG的疑问

  • nebula 版本:2.0
  • 部署方式:分布式
  • 问题:给点设定多TAG的疑问
  • 具体描述
    之前看手册中说可以给一个点赋多TAG,其在手册中运用方式为:
nebula> CREATE TAG t3(p1 int);
nebula> CREATE TAG t4(p2 string);
nebula> INSERT VERTEX  t3 (p1), t4(p2) VALUES "21": (321, "hello");   -- Insert vertex "21" with two tags.

那么当TAG属性为多种时,可否给一个定点多个TAG值?我在代码中尝试了相关操作,第二种方式成功,但无法在MATCH语句中通过player{name:"Tim Duncan"}匹配到,代码如下:

(root@nebula) [nba]> INSERT VERTEX player(name, age), playerext(name) VALUES "player100":(("Tim Duncan", 42), ("Tim"));
[ERROR (-7)]: SyntaxError: syntax error near `, 42), ('

Fri, 25 Dec 2020 14:07:50 CST

(root@nebula) [nba]> INSERT VERTEX player(name, age), playerext(name) VALUES "player100":("Tim Duncan", 42, "Tim");
Execution succeeded (time spent 2675/51487 us)

(root@nebula) [nba]> MATCH (v) WHERE id(v) == 'player100' RETURN v;
+--------------------------------------------------------------------------+
| v                                                                        |
+--------------------------------------------------------------------------+
| ("player100") :playerext{name:"Tim",  :player{name:"Tim Duncan", age:42} |
+--------------------------------------------------------------------------+
Got 1 rows (time spent 1846/55310 us)

Fri, 25 Dec 2020 14:22:11 CST

(root@nebula) [nba]> MATCH (v:player{name:"Tim Duncan"}) RETURN v;
Empty set (time spent 5198/54298 us)

Fri, 25 Dec 2020 14:22:45 CST

想问一下是我创建节点的方式有误还是MATCH语句撰写方式有误。

match通过属性查询是需要索引的

嗯嗯,是存在player(name)的索引的,我删除节点重新插入、更新索引、查询,但仍然无法查询到。
删除和建立节点,更新索引日志如下:

(root@nebula) [nba]> DELETE VERTEX "player100";
Execution succeeded (time spent 6306/55881 us)

Fri, 25 Dec 2020 14:41:28 CST

(root@nebula) [nba]> INSERT VERTEX player(name, age), playerext(name) VALUES "player100":("Tim Duncan", 42, "Tim");
Execution succeeded (time spent 5012/302480 us)

Fri, 25 Dec 2020 14:41:46 CST

(root@nebula) [nba]> REBUILD TAG INDEX name_single_1
+------------+
| New Job Id |
+------------+
| 26         |
+------------+
Got 1 rows (time spent 4041/53011 us)

Fri, 25 Dec 2020 14:41:51 CST

此时,可以通过MATCH的id属性查询到此节点,可以通过player{name}属性查询到此前存在的"Tony Parker"节点,但无法查询到新存入的"Tim Duncan"节点

(root@nebula) [nba]> MATCH (v) WHERE id(v) == 'player100' RETURN v;
+--------------------------------------------------------------------------+
| v                                                                        |
+--------------------------------------------------------------------------+
| ("player100") :playerext{name:"Tim",  :player{age:42, name:"Tim Duncan"} |
+--------------------------------------------------------------------------+
Got 1 rows (time spent 2129/51787 us)

Fri, 25 Dec 2020 14:42:47 CST

(root@nebula) [nba]>  MATCH (v:player{name:"Tony Parker"}) RETURN v;
+---------------------------------------------------+
| v                                                 |
+---------------------------------------------------+
| ("player101") :player{name:"Tony Parker", age:36} |
+---------------------------------------------------+
Got 1 rows (time spent 3482/52620 us)

Fri, 25 Dec 2020 14:43:29 CST

(root@nebula) [nba]>  MATCH (v:player{name:"Tim Duncan"}) RETURN v;
Empty set (time spent 3397/52453 us)

Fri, 25 Dec 2020 14:43:51 CST

检查一下job是否完成,如果完成在重试查询

浙ICP备20010487号