Search code examples
orientdborientdb-2.1orientdb2.2

Orientdb getVertices() returing Vertex for any label present in database


I am using Orientdb 2.2.10.

What I want to achieve?

I want to get a vertex of a particular vertexType - e.g vertexType = 'Person'.

My graphdb is indexed with unique key('uid').

What I am doing to achieve it?

  • getVertices(lable, []iKey, []iValue)
  • I am getting the desire vertex

what is problem with this method? :-

  • I am getting the desire vertex even when I provide any label(which is present in the database) name

e.g:-

  • I want to get a vertex of vertextype = 'Person' having uid = 'ram'

  • I am getting this vertex even when I provide any label (e.g "Relation") which is present in database.

Is this a bug or I am doing something wrong?

Thanks..!


Solution

  • I replicated your structure.

    enter code here

    I have tried with this code

    String [] keys=new String[]{"uid"};
    String [] values=new String[]{"ram"};
    Iterable<Vertex> it= g.getVertices("Person", keys, values);
    for(Vertex v:it){
        System.out.println(v.getId());
        System.out.println(v.getProperty("uid"));
    }
    

    and I obtained

    #21:0 ram

    while with

    String [] keys=new String[]{"uid"};
    String [] values=new String[]{"ram"};
    Iterable<Vertex> it= g.getVertices("Relational", keys, values);
    for(Vertex v:it){
        System.out.println(v.getId());
        System.out.println(v.getProperty("uid"));
    }
    

    I got nothing.

    Hope it helps.