You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Marko A. Rodriguez (JIRA)" <ji...@apache.org> on 2015/06/03 06:04:49 UTC

[jira] [Closed] (TINKERPOP3-551) Neo4j multiple labels can not be queried individually

     [ https://issues.apache.org/jira/browse/TINKERPOP3-551?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marko A. Rodriguez closed TINKERPOP3-551.
-----------------------------------------
       Resolution: Fixed
    Fix Version/s: 3.0.0.GA
         Assignee: Marko A. Rodriguez

This is complete. It was really easy. I added {{LabelP}} which extends {{P}}.

{code}
g.V.has(label,of('person'))
{code}

Here is the test case the validates the behavior:

{code}
    @Test
    public void shouldSupportHasContainersWithMultiLabels() throws Exception {
        final Neo4jVertex vertex = (Neo4jVertex) this.graph.addVertex(T.label,"person","name","marko");
        graph.tx().commit();
        assertTrue(g.V().has(T.label, "person").hasNext());
        assertEquals("marko", g.V().has(T.label, LabelP.of("person")).values("name").next());
        assertEquals("marko", g.V().has(T.label, "person").values("name").next());
        // more labels
        vertex.addLabel("animal");
        vertex.addLabel("object");
        graph.tx().commit();
        // no indices (neo4j graph step)
        assertFalse(g.V().has(T.label, "person").hasNext());
        assertEquals("marko", g.V().has(T.label, LabelP.of("person")).values("name").next());
        assertEquals("marko", g.V().has(T.label, LabelP.of("animal")).values("name").next());
        assertEquals("marko", g.V().has(T.label, LabelP.of("object")).values("name").next());
        // no indices (has step)
        assertFalse(g.V().as("a").select("a").has(T.label, "person").hasNext());
        assertEquals("marko", g.V().as("a").select("a").has(T.label, LabelP.of("person")).values("name").next());
        assertEquals("marko", g.V().as("a").select("a").has(T.label, LabelP.of("animal")).values("name").next());
        assertEquals("marko", g.V().as("a").select("a").has(T.label, LabelP.of("object")).values("name").next());
        // indices (neo4j graph step)
        this.getGraph().cypher("CREATE INDEX ON :person(name)").iterate();
        graph.tx().commit();
        Thread.sleep(500);
        assertFalse(g.V().has(T.label, "person").has("name", "marko").hasNext());
        assertEquals("marko", g.V().has(T.label, LabelP.of("person")).has("name", "marko").values("name").next());
        assertEquals("marko", g.V().has(T.label, LabelP.of("animal")).has("name","marko").values("name").next());
        assertEquals("marko", g.V().has(T.label, LabelP.of("object")).has("name","marko").values("name").next());
        this.getGraph().cypher("CREATE INDEX ON :animal(name)").iterate();
        graph.tx().commit();
        Thread.sleep(500);
        assertFalse(g.V().has(T.label, "animal").has("name", "marko").hasNext());
        assertEquals("marko", g.V().has(T.label, LabelP.of("person")).has("name", "marko").values("name").next());
        assertEquals("marko", g.V().has(T.label, LabelP.of("animal")).has("name","marko").values("name").next());
        assertEquals("marko", g.V().has(T.label, LabelP.of("object")).has("name","marko").values("name").next());
        this.getGraph().cypher("CREATE INDEX ON :object(name)").iterate();
        graph.tx().commit();
        Thread.sleep(500);
        assertFalse(g.V().has(T.label, "object").has("name", "marko").hasNext());
        assertEquals("marko", g.V().has(T.label, LabelP.of("person")).has("name", "marko").values("name").next());
        assertEquals("marko", g.V().has(T.label, LabelP.of("animal")).has("name","marko").values("name").next());
        assertEquals("marko", g.V().has(T.label, LabelP.of("object")).has("name","marko").values("name").next());
    }
{code}

> Neo4j multiple labels can not be queried individually
> -----------------------------------------------------
>
>                 Key: TINKERPOP3-551
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP3-551
>             Project: TinkerPop 3
>          Issue Type: Bug
>          Components: neo4j
>            Reporter: Stanislav Malyshev
>            Assignee: Marko A. Rodriguez
>            Priority: Critical
>             Fix For: 3.0.0.GA
>
>
> With TP3 M7, I can add multiple labels to Neo4j vertex:
> {code}
> gremlin> v = g.addVertex(label, 'test', 'wikibaseId', 'test')
> ==>v[3]
> gremlin> v.addLabel('test2')
> ==>null
> gremlin> v.labels()
> ==>test
> ==>test2
> {code}
> However, if I try a lookup by this label, it does not work:
> {code}
> gremlin> g.V().has(label, 'test2')
> gremlin> g.V().has(label, 'test')
> gremlin> g.V().has(label, 'test').hasNext()
> ==>false
> {code}
> This lookup works for nodes with single label, but not for nodes with multiple labels. This, however, works:
> {code}
> gremlin> g.cypher('MATCH (x:test2) RETURN x')
> ==>[x:v[3]]
> {code}
> So Neo4j query works fine, while TP3 one does not.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)