Skip to content

在ID建唯一索引,web界面用g.V().has("id","1223")查询报错 #795

Closed

Description

@CPJ-data

Expected behavior 期望表现

使用g.V().has("id","1223")
可查出该点信息。

Actual behavior 实际表现

g.V().has("eid","1702")
Error!
Unknown index type 'UNIQUE'
使用g.V().hasLabel("person").has("eid","1702")
Error!
Unknown index type 'UNIQUE'

Steps to reproduce the problem 复现步骤

  1. {step 1}
  2. {step 2}
  3. {step 3}

Status of loaded data 数据状态

Vertex/Edge summary 数据量

  • loaded vertices amount: {like 10 million}
  • loaded edges amount: {like 20 million}
  • loaded time: {like 200s}

Vertex/Edge example 数据示例

{type something here...}

Schema(VertexLabel, EdgeLabel, IndexLabel) 元数据结构

{type something here...}

Specifications of environment 环境信息

  • hugegraph version: {like v0.7.4}
  • operating system: {like centos 7.4, 32 CPUs, 64G RAM}
  • hugegraph backend: {like cassandra 3.10, cluster with 20 nodes, 3 x 1TB HDD disk each node}

Activity

  1. zhoney commented on Dec 26, 2019

    @zhoney
    Contributor

    @CPJ-data 目前unique index只是一种约束索引,并不支持查询。如果要查询可以根据数据类型建立其他索引。

    即使目前不支持unique index的查询,但返回的信息并非预期的,我们会尽快修复,谢谢反馈!

  2. added a commit that references this issue on Dec 26, 2019
    f9d2f69
  3. CPJ-data commented on Dec 27, 2019

    @CPJ-data
    Author

    @zhoney
    定义schema:
    schema.indexLabel("personByEid")
    .onV("person")
    .by("eid")
    .secondary()
    .unique()
    .ifNotExist(
    .create();
    查询语句:g.V().has("eid","1702")

  4. added a commit that references this issue on Jan 7, 2020
    81c1853
  5. CPJ-data commented on Jan 13, 2020

    @CPJ-data
    Author

    @zhoney @Linary
    测试了唯一索引,在schema中对于某个ID,如uid设置唯一索引,但是在插入数据的时候可以重复进行插入 ——>如该数据
    Vertex marko = graph.addVertex(T.label, "person", "name", "杨过", "eid", "1702","age", 28, "city", "唐宋元明清","uid","1702");
    第一次插入图后,再次插入同一条数据也是可以插入成功并不会报错唯一索引的错误,而且界面上的显示也是多条一样的数据(插入多少次就显示多少条数据)。
    定义了唯一索引的字段,通过唯一索引的字段可以进行点的查询,重复数据不会报唯一索引错误。
    定义唯一索引:
    schema.indexLabel("personByUid")
    .onV("person")
    .by("uid")
    .unique()
    .secondary()
    .ifNotExist()
    .create();

  6. zhoney commented on Mar 4, 2020

    @zhoney
    Contributor

    @CPJ-data

    schema.indexLabel("personByUid")
    .onV("person")
    .by("uid")
    .unique()
    .secondary()
    .ifNotExist()
    .create();
    

    建立的是二级索引(secondary index),而不是唯一索引(unique index)。二级索引是支持查询的,唯一索引仅能够限制值不重复,不能用于查询。

    第一次插入图后,再次插入同一条数据也是可以插入成功并不会报错唯一索引的错误,而且界面上的显示也是多条一样的数据(插入多少次就显示多少条数据)。
    定义了唯一索引的字段,通过唯一索引的字段可以进行点的查询,重复数据不会报唯一索引错误。
    

    这是因为创建了二级索引,且顶点使用的是自动id的策略,所以每增加一条,就多一个顶点,虽然属性都一样,但是id却不同,因此是不同的顶点。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions