You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/06/08 17:21:55 UTC

incubator-tinkerpop git commit: LabelP.of() is smart about situations like organism-animal as it now checks on Neo4jVertex.LABEL_DELIMINATOR. Test case added.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master eecc6110c -> d299705e9


LabelP.of() is smart about situations like organism-animal as it now checks on Neo4jVertex.LABEL_DELIMINATOR. Test case added.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/d299705e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/d299705e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/d299705e

Branch: refs/heads/master
Commit: d299705e9aaaa523d85e0848e6e605730c1749ee
Parents: eecc611
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Mon Jun 8 09:21:50 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Mon Jun 8 09:21:50 2015 -0600

----------------------------------------------------------------------
 docs/src/implementations.asciidoc               |   4 +-
 .../gremlin/neo4j/process/traversal/LabelP.java |   3 +-
 .../neo4j/structure/NativeNeo4jIndexTest.java   | 250 ++++++++++++++++
 .../structure/NativeNeo4jStructureTest.java     | 291 ++-----------------
 4 files changed, 285 insertions(+), 263 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d299705e/docs/src/implementations.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/implementations.asciidoc b/docs/src/implementations.asciidoc
index aab0aeb..e4f791a 100644
--- a/docs/src/implementations.asciidoc
+++ b/docs/src/implementations.asciidoc
@@ -663,12 +663,12 @@ vertex.removeLabel('human') // remove a label that doesn't exist
 vertex.label()
 g = graph.traversal()
 g.V().has(label,'organism') // does not match as P.eq() does a full string match
-g.V().has(label,of('organism')) // N.of() is specific to neo4j-gremlin and used for multi-label matching
+g.V().has(label,of('organism')) // LabelP.of() is specific to neo4j-gremlin and used for multi-label matching
 g.V().has(label,of('organism')).has(label,of('animal'))
 g.V().has(label,of('organism').and(of('animal')))
 ----
 
-`N.of()` is only required if multi-labels are leveraged. `N.of()` is used when filtering/looking-up vertices by their label(s) as the standard `P.eq()` does a direct match on the `::`-representation of `vertex.label()`
+`LabelP.of()` is only required if multi-labels are leveraged. `LabelP.of()` is used when filtering/looking-up vertices by their label(s) as the standard `P.eq()` does a direct match on the `::`-representation of `vertex.label()`
 
 [[hadoop-gremlin]]
 Hadoop-Gremlin

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d299705e/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/LabelP.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/LabelP.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/LabelP.java
index 7c3414c..c9070be 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/LabelP.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/LabelP.java
@@ -21,6 +21,7 @@
 
 package org.apache.tinkerpop.gremlin.neo4j.process.traversal;
 
+import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jVertex;
 import org.apache.tinkerpop.gremlin.process.traversal.P;
 
 import java.io.Serializable;
@@ -48,7 +49,7 @@ public final class LabelP extends P<String> {
 
         @Override
         public boolean test(final String labels, final String checkLabel) {
-            return labels.contains(checkLabel); // TODO: contains may be bad -- use :: reg-ex parsing?
+            return labels.equals(checkLabel) || labels.contains(Neo4jVertex.LABEL_DELIMINATOR + checkLabel) || labels.contains(checkLabel + Neo4jVertex.LABEL_DELIMINATOR);
         }
 
         public static LabelBiPredicate instance() {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d299705e/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jIndexTest.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jIndexTest.java b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jIndexTest.java
index 642ff77..5de1cf4 100644
--- a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jIndexTest.java
+++ b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jIndexTest.java
@@ -23,10 +23,13 @@ package org.apache.tinkerpop.gremlin.neo4j.structure;
 
 import org.apache.tinkerpop.gremlin.FeatureRequirement;
 import org.apache.tinkerpop.gremlin.neo4j.AbstractNeo4jGremlinTest;
+import org.apache.tinkerpop.gremlin.neo4j.structure.trait.MultiMetaNeo4jTrait;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
 import org.apache.tinkerpop.gremlin.util.TimeUtil;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Test;
@@ -118,4 +121,251 @@ public class NativeNeo4jIndexTest extends AbstractNeo4jGremlinTest {
         System.out.println("Query time (no-index vs. index): " + noIndexTime + " vs. " + indexTime);
         assertTrue((noIndexTime / 10) > indexTime); // should be at least 10x faster
     }
+
+    @Test
+    public void shouldReturnResultsLabeledIndexOnVertexWithHasHas() {
+        this.graph.tx().readWrite();
+        this.getBaseGraph().execute("CREATE INDEX ON :Person(name)", null);
+        this.graph.tx().commit();
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+        this.graph.tx().commit();
+        assertEquals(2, this.g.V().has(T.label, "Person").has("name", "marko").count().next(), 0);
+        assertEquals(2, this.g.V().has("name", "marko").count().next(), 0);
+    }
+
+    @Test
+    public void shouldEnsureColonedKeyIsTreatedAsNormalKey() {
+        this.graph.tx().readWrite();
+        this.getBaseGraph().execute("CREATE INDEX ON :Person(name)", null);
+        this.graph.tx().commit();
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+        this.graph.tx().commit();
+        assertEquals(2, this.g.V().has(T.label, "Person").has("name", "marko").count().next(), 0);
+        assertEquals(0, this.g.V().has("Person:name", "marko").count().next(), 0);
+    }
+
+    @Test
+    public void shouldReturnResultsUsingLabeledIndexOnVertexWithHasHasHas() {
+        this.graph.tx().readWrite();
+        this.getBaseGraph().execute("CREATE INDEX ON :Person(name)", null);
+        this.graph.tx().commit();
+        this.graph.addVertex(T.label, "Person", "name", "marko", "color", "blue");
+        this.graph.addVertex(T.label, "Person", "name", "marko", "color", "green");
+        this.graph.tx().commit();
+        assertEquals(1, this.g.V().has(T.label, "Person").has("name", "marko").has("color", "blue").count().next(), 0);
+        assertEquals(2, this.g.V().has("name", "marko").count().next(), 0);
+    }
+
+    @Test
+    public void shouldReturnResultsOnVertexWithHasHasHasNoIndex() {
+        this.graph.tx().commit();
+        this.graph.addVertex(T.label, "Person", "name", "marko", "color", "blue");
+        this.graph.addVertex(T.label, "Person", "name", "marko", "color", "green");
+        this.graph.tx().commit();
+        assertEquals(1, this.g.V().has(T.label, "Person").has("name", "marko").has("color", "blue").count().next(), 0);
+        assertEquals(2, this.g.V().has("name", "marko").count().next(), 0);
+    }
+
+    @Test
+    public void shouldReturnResultsUsingLabeledIndexOnVertexWithColonFails() {
+        this.graph.tx().readWrite();
+        this.getBaseGraph().execute("CREATE INDEX ON :Person(name)", null);
+        this.graph.tx().commit();
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+        this.graph.tx().commit();
+        assertNotEquals(2l, this.g.V().has("Person:name", "marko").count().next().longValue());
+        assertEquals(2, this.g.V().has("name", "marko").count().next(), 0);
+    }
+
+    @Test
+    public void shouldEnforceUniqueConstraint() {
+        this.graph.tx().readWrite();
+        this.getBaseGraph().execute("CREATE CONSTRAINT ON (p:Person) assert p.name is unique", null);
+        this.graph.tx().commit();
+        this.graph.tx().commit();
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+        this.graph.tx().commit();
+        assertEquals("marko", g.V().has(T.label, "Person").has("name", "marko").next().value("name"));
+    }
+
+    @Test
+    public void shouldEnforceMultipleUniqueConstraint() {
+        this.graph.tx().readWrite();
+        this.getBaseGraph().execute("CREATE CONSTRAINT ON (p:Person) assert p.name is unique", null);
+        this.getBaseGraph().execute("CREATE CONSTRAINT ON (p:Person) assert p.surname is unique", null);
+        this.graph.tx().commit();
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+        this.graph.addVertex(T.label, "Person", "surname", "aaaa");
+        this.graph.tx().commit();
+        boolean failSurname = false;
+        try {
+            this.graph.addVertex(T.label, "Person", "surname", "aaaa");
+        } catch (RuntimeException e) {
+            if (isConstraintViolation(e)) failSurname = true;
+        }
+        assertTrue(failSurname);
+        boolean failName = false;
+        try {
+            this.graph.addVertex(T.label, "Person", "name", "marko");
+        } catch (RuntimeException e) {
+            if (isConstraintViolation(e)) failName = true;
+        }
+        assertTrue(failName);
+        this.graph.tx().commit();
+    }
+
+    private boolean isConstraintViolation(RuntimeException e) {
+        return e.getClass().getSimpleName().equals("ConstraintViolationException");
+    }
+
+    @Test
+    public void shouldDropMultipleUniqueConstraint() {
+        this.graph.tx().readWrite();
+        this.getBaseGraph().execute("CREATE CONSTRAINT ON (p:Person) assert p.name is unique", null);
+        this.getBaseGraph().execute("CREATE CONSTRAINT ON (p:Person) assert p.surname is unique", null);
+        this.graph.tx().commit();
+
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+        this.graph.addVertex(T.label, "Person", "surname", "aaaa");
+        this.graph.tx().commit();
+        boolean failSurname = false;
+        try {
+            this.graph.addVertex(T.label, "Person", "surname", "aaaa");
+        } catch (RuntimeException e) {
+            if (isConstraintViolation(e)) failSurname = true;
+        }
+        assertTrue(failSurname);
+        boolean failName = false;
+        try {
+            this.graph.addVertex(T.label, "Person", "name", "marko");
+        } catch (RuntimeException e) {
+            if (isConstraintViolation(e)) failName = true;
+        }
+        assertTrue(failName);
+        this.graph.tx().commit();
+
+        this.graph.tx().readWrite();
+        this.getBaseGraph().execute("DROP CONSTRAINT ON (p:Person) assert p.name is unique", null);
+        this.getBaseGraph().execute("DROP CONSTRAINT ON (p:Person) assert p.surname is unique", null);
+
+        this.graph.tx().commit();
+        assertEquals(1, this.g.V().has(T.label, "Person").has("name", "marko").count().next(), 0);
+        assertEquals(1, this.g.V().has(T.label, "Person").has("surname", "aaaa").count().next(), 0);
+        this.graph.addVertex(T.label, "Person", "surname", "aaaa");
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+        this.graph.tx().commit();
+        assertEquals(2, this.g.V().has(T.label, "Person").has("name", "marko").count().next(), 0);
+        assertEquals(2, this.g.V().has(T.label, "Person").has("surname", "aaaa").count().next(), 0);
+    }
+
+    @Test(expected = RuntimeException.class)
+    public void shouldFailUniqueConstraint() {
+        this.graph.tx().readWrite();
+        this.getBaseGraph().execute("CREATE CONSTRAINT ON (p:Person) assert p.name is unique", null);
+        this.graph.tx().commit();
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+        this.graph.tx().commit();
+        assertEquals("marko", g.V().has(T.label, "Person").has("name", "marko").next().value("name"));
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+    }
+
+    @Test
+    public void shouldDoLabelAndIndexSearch() {
+        graph.tx().readWrite();
+        this.getBaseGraph().execute("CREATE INDEX ON :Person(name)", null);
+        this.graph.tx().commit();
+
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+        this.graph.addVertex(T.label, "Person", "name", "john");
+        this.graph.addVertex(T.label, "Person", "name", "pete");
+        this.graph.tx().commit();
+        assertEquals(1, this.g.V().has("Person", "name", "marko").count().next(), 0);
+        assertEquals(3, this.g.V().has(T.label, "Person").count().next(), 0);
+        assertEquals(1, this.g.V().has(T.label, "Person").has("name", "marko").count().next(), 0);
+    }
+
+    @Test
+    @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_MULTI_PROPERTIES)
+    public void shouldSupportVertexPropertyToVertexMappingOnIndexCalls() {
+        graph.tx().readWrite();
+        this.getBaseGraph().execute("CREATE INDEX ON :person(name)", null);
+//            this.graph.getBaseGraph().execute("CREATE INDEX ON :name(" + T.value.getAccessor() + ")", null);
+        this.graph.tx().commit();
+
+        final Vertex a = graph.addVertex(T.label, "person", "name", "marko", "age", 34);
+        a.property(VertexProperty.Cardinality.list, "name", "okram");
+        a.property(VertexProperty.Cardinality.list, "name", "marko a. rodriguez");
+        final Vertex b = graph.addVertex(T.label, "person", "name", "stephen");
+        final Vertex c = graph.addVertex("name", "matthias", "name", "mbroecheler");
+
+        tryCommit(graph, graph -> {
+            assertEquals(a.id(), g.V().has("person", "name", "okram").id().next());
+            assertEquals(1, g.V().has("person", "name", "okram").count().next().intValue());
+            assertEquals(34, ((Neo4jVertex) g.V().has("person", "name", "okram").next()).getBaseVertex().getProperty("age"));
+            assertEquals(MultiMetaNeo4jTrait.VERTEX_PROPERTY_TOKEN, ((Neo4jVertex) g.V().has("person", "name", "okram").next()).getBaseVertex().getProperty("name"));
+            ///
+            assertEquals(b.id(), g.V().has("person", "name", "stephen").id().next());
+            assertEquals(1, g.V().has("person", "name", "stephen").count().next().intValue());
+            assertEquals("stephen", ((Neo4jVertex) g.V().has("person", "name", "stephen").next()).getBaseVertex().getProperty("name"));
+            ///
+            assertEquals(c.id(), g.V().has("name", "matthias").id().next());
+            assertEquals(c.id(), g.V().has("name", "mbroecheler").id().next());
+            assertEquals(1, g.V().has("name", "matthias").count().next().intValue());
+            assertEquals(1, g.V().has("name", "mbroecheler").count().next().intValue());
+            assertEquals(0, g.V().has("person", "name", "matthias").count().next().intValue());
+            assertEquals(0, g.V().has("person", "name", "mbroecheler").count().next().intValue());
+        });
+
+        final Vertex d = graph.addVertex(T.label, "person", "name", "kuppitz");
+        tryCommit(graph, graph -> {
+            assertEquals(d.id(), g.V().has("person", "name", "kuppitz").id().next());
+            assertEquals("kuppitz", ((Neo4jVertex) g.V().has("person", "name", "kuppitz").next()).getBaseVertex().getProperty("name"));
+        });
+        d.property(VertexProperty.Cardinality.list, "name", "daniel", "acl", "private");
+        tryCommit(graph, graph -> {
+            assertEquals(d.id(), g.V().has("person", "name", P.within("daniel", "kuppitz")).id().next());
+            assertEquals(d.id(), g.V().has("person", "name", "kuppitz").id().next());
+            assertEquals(d.id(), g.V().has("person", "name", "daniel").id().next());
+            assertEquals(MultiMetaNeo4jTrait.VERTEX_PROPERTY_TOKEN, ((Neo4jVertex) g.V().has("person", "name", "kuppitz").next()).getBaseVertex().getProperty("name"));
+        });
+        d.property(VertexProperty.Cardinality.list, "name", "marko", "acl", "private");
+        tryCommit(graph, graph -> {
+            assertEquals(2, g.V().has("person", "name", "marko").count().next().intValue());
+            assertEquals(1, g.V().has("person", "name", "marko").properties("name").has(T.value, "marko").has("acl", "private").count().next().intValue());
+            g.V().has("person", "name", "marko").forEachRemaining(v -> {
+                assertEquals(MultiMetaNeo4jTrait.VERTEX_PROPERTY_TOKEN, ((Neo4jVertex) v).getBaseVertex().getProperty("name"));
+            });
+
+        });
+    }
+
+    @Test
+    public void shouldDoLabelsNamespaceBehavior() {
+        graph.tx().readWrite();
+
+        this.getBaseGraph().execute("CREATE INDEX ON :Person(name)", null);
+        this.getBaseGraph().execute("CREATE INDEX ON :Product(name)", null);
+        this.getBaseGraph().execute("CREATE INDEX ON :Corporate(name)", null);
+
+        this.graph.tx().commit();
+        this.graph.addVertex(T.label, "Person", "name", "marko");
+        this.graph.addVertex(T.label, "Person", "name", "john");
+        this.graph.addVertex(T.label, "Person", "name", "pete");
+        this.graph.addVertex(T.label, "Product", "name", "marko");
+        this.graph.addVertex(T.label, "Product", "name", "john");
+        this.graph.addVertex(T.label, "Product", "name", "pete");
+        this.graph.addVertex(T.label, "Corporate", "name", "marko");
+        this.graph.addVertex(T.label, "Corporate", "name", "john");
+        this.graph.addVertex(T.label, "Corporate", "name", "pete");
+        this.graph.tx().commit();
+        assertEquals(1, this.g.V().has(T.label, "Person").has("name", "marko").has(T.label, "Person").count().next(), 0);
+        assertEquals(1, this.g.V().has(T.label, "Product").has("name", "marko").has(T.label, "Product").count().next(), 0);
+        assertEquals(1, this.g.V().has(T.label, "Corporate").has("name", "marko").has(T.label, "Corporate").count().next(), 0);
+        assertEquals(0, this.g.V().has(T.label, "Person").has("name", "marko").has(T.label, "Product").count().next(), 0);
+        assertEquals(0, this.g.V().has(T.label, "Product").has("name", "marko").has(T.label, "Person").count().next(), 0);
+        assertEquals(0, this.g.V().has(T.label, "Corporate").has("name", "marko").has(T.label, "Person").count().next(), 0);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d299705e/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jStructureTest.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jStructureTest.java b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jStructureTest.java
index f467f32..2625a71 100644
--- a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jStructureTest.java
+++ b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jStructureTest.java
@@ -26,7 +26,7 @@ import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine;
 import org.apache.tinkerpop.gremlin.neo4j.AbstractNeo4jGremlinTest;
 import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP;
 import org.apache.tinkerpop.gremlin.neo4j.structure.trait.MultiMetaNeo4jTrait;
-import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -60,7 +60,7 @@ public class NativeNeo4jStructureTest extends AbstractNeo4jGremlinTest {
 
     @Test
     public void shouldSupportHasContainersWithMultiLabels() throws Exception {
-        final Neo4jVertex vertex = (Neo4jVertex) this.graph.addVertex(T.label,"person","name","marko");
+        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());
@@ -85,22 +85,22 @@ public class NativeNeo4jStructureTest extends AbstractNeo4jGremlinTest {
         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());
+        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());
+        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());
+        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());
     }
 
     @Test
@@ -131,157 +131,6 @@ public class NativeNeo4jStructureTest extends AbstractNeo4jGremlinTest {
     }
 
     @Test
-    public void shouldReturnResultsLabeledIndexOnVertexWithHasHas() {
-        this.graph.tx().readWrite();
-        this.getBaseGraph().execute("CREATE INDEX ON :Person(name)", null);
-        this.graph.tx().commit();
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-        this.graph.tx().commit();
-        assertEquals(2, this.g.V().has(T.label, "Person").has("name", "marko").count().next(), 0);
-        assertEquals(2, this.g.V().has("name", "marko").count().next(), 0);
-    }
-
-    @Test
-    public void shouldEnsureColonedKeyIsTreatedAsNormalKey() {
-        this.graph.tx().readWrite();
-        this.getBaseGraph().execute("CREATE INDEX ON :Person(name)", null);
-        this.graph.tx().commit();
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-        this.graph.tx().commit();
-        assertEquals(2, this.g.V().has(T.label, "Person").has("name", "marko").count().next(), 0);
-        assertEquals(0, this.g.V().has("Person:name", "marko").count().next(), 0);
-
-    }
-
-    @Test
-    public void shouldReturnResultsUsingLabeledIndexOnVertexWithHasHasHas() {
-        this.graph.tx().readWrite();
-        this.getBaseGraph().execute("CREATE INDEX ON :Person(name)", null);
-        this.graph.tx().commit();
-        this.graph.addVertex(T.label, "Person", "name", "marko", "color", "blue");
-        this.graph.addVertex(T.label, "Person", "name", "marko", "color", "green");
-        this.graph.tx().commit();
-        assertEquals(1, this.g.V().has(T.label, "Person").has("name", "marko").has("color", "blue").count().next(), 0);
-        assertEquals(2, this.g.V().has("name", "marko").count().next(), 0);
-    }
-
-    @Test
-    public void shouldReturnResultsOnVertexWithHasHasHasNoIndex() {
-        this.graph.tx().commit();
-        this.graph.addVertex(T.label, "Person", "name", "marko", "color", "blue");
-        this.graph.addVertex(T.label, "Person", "name", "marko", "color", "green");
-        this.graph.tx().commit();
-        assertEquals(1, this.g.V().has(T.label, "Person").has("name", "marko").has("color", "blue").count().next(), 0);
-        assertEquals(2, this.g.V().has("name", "marko").count().next(), 0);
-    }
-
-    @Test
-    public void shouldReturnResultsUsingLabeledIndexOnVertexWithColonFails() {
-        this.graph.tx().readWrite();
-        this.getBaseGraph().execute("CREATE INDEX ON :Person(name)", null);
-        this.graph.tx().commit();
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-        this.graph.tx().commit();
-        assertNotEquals(2l, this.g.V().has("Person:name", "marko").count().next().longValue());
-        assertEquals(2, this.g.V().has("name", "marko").count().next(), 0);
-    }
-
-    @Test
-    public void shouldEnforceUniqueConstraint() {
-        this.graph.tx().readWrite();
-        this.getBaseGraph().execute("CREATE CONSTRAINT ON (p:Person) assert p.name is unique", null);
-        this.graph.tx().commit();
-        this.graph.tx().commit();
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-        this.graph.tx().commit();
-        assertEquals("marko", g.V().has(T.label, "Person").has("name", "marko").next().value("name"));
-    }
-
-    @Test
-    public void shouldEnforceMultipleUniqueConstraint() {
-        this.graph.tx().readWrite();
-        this.getBaseGraph().execute("CREATE CONSTRAINT ON (p:Person) assert p.name is unique", null);
-        this.getBaseGraph().execute("CREATE CONSTRAINT ON (p:Person) assert p.surname is unique", null);
-        this.graph.tx().commit();
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-        this.graph.addVertex(T.label, "Person", "surname", "aaaa");
-        this.graph.tx().commit();
-        boolean failSurname = false;
-        try {
-            this.graph.addVertex(T.label, "Person", "surname", "aaaa");
-        } catch (RuntimeException e) {
-            if (isConstraintViolation(e)) failSurname = true;
-        }
-        assertTrue(failSurname);
-        boolean failName = false;
-        try {
-            this.graph.addVertex(T.label, "Person", "name", "marko");
-        } catch (RuntimeException e) {
-            if (isConstraintViolation(e)) failName = true;
-        }
-        assertTrue(failName);
-        this.graph.tx().commit();
-    }
-
-    private boolean isConstraintViolation(RuntimeException e) {
-        return e.getClass().getSimpleName().equals("ConstraintViolationException");
-    }
-
-    @Test
-    public void shouldDropMultipleUniqueConstraint() {
-        this.graph.tx().readWrite();
-        this.getBaseGraph().execute("CREATE CONSTRAINT ON (p:Person) assert p.name is unique", null);
-        this.getBaseGraph().execute("CREATE CONSTRAINT ON (p:Person) assert p.surname is unique", null);
-        this.graph.tx().commit();
-
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-        this.graph.addVertex(T.label, "Person", "surname", "aaaa");
-        this.graph.tx().commit();
-        boolean failSurname = false;
-        try {
-            this.graph.addVertex(T.label, "Person", "surname", "aaaa");
-        } catch (RuntimeException e) {
-            if (isConstraintViolation(e)) failSurname = true;
-        }
-        assertTrue(failSurname);
-        boolean failName = false;
-        try {
-            this.graph.addVertex(T.label, "Person", "name", "marko");
-        } catch (RuntimeException e) {
-            if (isConstraintViolation(e)) failName = true;
-        }
-        assertTrue(failName);
-        this.graph.tx().commit();
-
-        this.graph.tx().readWrite();
-        this.getBaseGraph().execute("DROP CONSTRAINT ON (p:Person) assert p.name is unique", null);
-        this.getBaseGraph().execute("DROP CONSTRAINT ON (p:Person) assert p.surname is unique", null);
-
-        this.graph.tx().commit();
-        assertEquals(1, this.g.V().has(T.label, "Person").has("name", "marko").count().next(), 0);
-        assertEquals(1, this.g.V().has(T.label, "Person").has("surname", "aaaa").count().next(), 0);
-        this.graph.addVertex(T.label, "Person", "surname", "aaaa");
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-        this.graph.tx().commit();
-        assertEquals(2, this.g.V().has(T.label, "Person").has("name", "marko").count().next(), 0);
-        assertEquals(2, this.g.V().has(T.label, "Person").has("surname", "aaaa").count().next(), 0);
-    }
-
-    @Test(expected = RuntimeException.class)
-    public void shouldFailUniqueConstraint() {
-        this.graph.tx().readWrite();
-        this.getBaseGraph().execute("CREATE CONSTRAINT ON (p:Person) assert p.name is unique", null);
-        this.graph.tx().commit();
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-        this.graph.tx().commit();
-        assertEquals("marko", g.V().has(T.label, "Person").has("name", "marko").next().value("name"));
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-    }
-
-    @Test
     public void shouldEnsureTraverseRelationshipNeedsTx() throws ScriptException {
         final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine();
         final Bindings bindings = engine.createBindings();
@@ -337,103 +186,6 @@ public class NativeNeo4jStructureTest extends AbstractNeo4jGremlinTest {
     }
 
     @Test
-    public void shouldDoLabelAndIndexSearch() {
-        graph.tx().readWrite();
-        this.getBaseGraph().execute("CREATE INDEX ON :Person(name)", null);
-        this.graph.tx().commit();
-
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-        this.graph.addVertex(T.label, "Person", "name", "john");
-        this.graph.addVertex(T.label, "Person", "name", "pete");
-        this.graph.tx().commit();
-        assertEquals(1, this.g.V().has("Person", "name", "marko").count().next(), 0);
-        assertEquals(3, this.g.V().has(T.label, "Person").count().next(), 0);
-        assertEquals(1, this.g.V().has(T.label, "Person").has("name", "marko").count().next(), 0);
-    }
-
-    @Test
-    @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_MULTI_PROPERTIES)
-    public void shouldSupportVertexPropertyToVertexMappingOnIndexCalls() {
-        graph.tx().readWrite();
-        this.getBaseGraph().execute("CREATE INDEX ON :person(name)", null);
-//            this.graph.getBaseGraph().execute("CREATE INDEX ON :name(" + T.value.getAccessor() + ")", null);
-        this.graph.tx().commit();
-
-        final Vertex a = graph.addVertex(T.label, "person", "name", "marko", "age", 34);
-        a.property(VertexProperty.Cardinality.list, "name", "okram");
-        a.property(VertexProperty.Cardinality.list, "name", "marko a. rodriguez");
-        final Vertex b = graph.addVertex(T.label, "person", "name", "stephen");
-        final Vertex c = graph.addVertex("name", "matthias", "name", "mbroecheler");
-
-        tryCommit(graph, graph -> {
-            assertEquals(a.id(), g.V().has("person", "name", "okram").id().next());
-            assertEquals(1, g.V().has("person", "name", "okram").count().next().intValue());
-            assertEquals(34, ((Neo4jVertex) g.V().has("person", "name", "okram").next()).getBaseVertex().getProperty("age"));
-            assertEquals(MultiMetaNeo4jTrait.VERTEX_PROPERTY_TOKEN, ((Neo4jVertex) g.V().has("person", "name", "okram").next()).getBaseVertex().getProperty("name"));
-            ///
-            assertEquals(b.id(), g.V().has("person", "name", "stephen").id().next());
-            assertEquals(1, g.V().has("person", "name", "stephen").count().next().intValue());
-            assertEquals("stephen", ((Neo4jVertex) g.V().has("person", "name", "stephen").next()).getBaseVertex().getProperty("name"));
-            ///
-            assertEquals(c.id(), g.V().has("name", "matthias").id().next());
-            assertEquals(c.id(), g.V().has("name", "mbroecheler").id().next());
-            assertEquals(1, g.V().has("name", "matthias").count().next().intValue());
-            assertEquals(1, g.V().has("name", "mbroecheler").count().next().intValue());
-            assertEquals(0, g.V().has("person", "name", "matthias").count().next().intValue());
-            assertEquals(0, g.V().has("person", "name", "mbroecheler").count().next().intValue());
-        });
-
-        final Vertex d = graph.addVertex(T.label, "person", "name", "kuppitz");
-        tryCommit(graph, graph -> {
-            assertEquals(d.id(), g.V().has("person", "name", "kuppitz").id().next());
-            assertEquals("kuppitz", ((Neo4jVertex) g.V().has("person", "name", "kuppitz").next()).getBaseVertex().getProperty("name"));
-        });
-        d.property(VertexProperty.Cardinality.list, "name", "daniel", "acl", "private");
-        tryCommit(graph, graph -> {
-            assertEquals(d.id(), g.V().has("person", "name", P.within("daniel", "kuppitz")).id().next());
-            assertEquals(d.id(), g.V().has("person", "name", "kuppitz").id().next());
-            assertEquals(d.id(), g.V().has("person", "name", "daniel").id().next());
-            assertEquals(MultiMetaNeo4jTrait.VERTEX_PROPERTY_TOKEN, ((Neo4jVertex) g.V().has("person", "name", "kuppitz").next()).getBaseVertex().getProperty("name"));
-        });
-        d.property(VertexProperty.Cardinality.list, "name", "marko", "acl", "private");
-        tryCommit(graph, graph -> {
-            assertEquals(2, g.V().has("person", "name", "marko").count().next().intValue());
-            assertEquals(1, g.V().has("person", "name", "marko").properties("name").has(T.value, "marko").has("acl", "private").count().next().intValue());
-            g.V().has("person", "name", "marko").forEachRemaining(v -> {
-                assertEquals(MultiMetaNeo4jTrait.VERTEX_PROPERTY_TOKEN, ((Neo4jVertex) v).getBaseVertex().getProperty("name"));
-            });
-
-        });
-    }
-
-    @Test
-    public void shouldDoLabelsNamespaceBehavior() {
-        graph.tx().readWrite();
-
-        this.getBaseGraph().execute("CREATE INDEX ON :Person(name)", null);
-        this.getBaseGraph().execute("CREATE INDEX ON :Product(name)", null);
-        this.getBaseGraph().execute("CREATE INDEX ON :Corporate(name)", null);
-
-        this.graph.tx().commit();
-        this.graph.addVertex(T.label, "Person", "name", "marko");
-        this.graph.addVertex(T.label, "Person", "name", "john");
-        this.graph.addVertex(T.label, "Person", "name", "pete");
-        this.graph.addVertex(T.label, "Product", "name", "marko");
-        this.graph.addVertex(T.label, "Product", "name", "john");
-        this.graph.addVertex(T.label, "Product", "name", "pete");
-        this.graph.addVertex(T.label, "Corporate", "name", "marko");
-        this.graph.addVertex(T.label, "Corporate", "name", "john");
-        this.graph.addVertex(T.label, "Corporate", "name", "pete");
-        this.graph.tx().commit();
-        assertEquals(1, this.g.V().has(T.label, "Person").has("name", "marko").has(T.label, "Person").count().next(), 0);
-        assertEquals(1, this.g.V().has(T.label, "Product").has("name", "marko").has(T.label, "Product").count().next(), 0);
-        assertEquals(1, this.g.V().has(T.label, "Corporate").has("name", "marko").has(T.label, "Corporate").count().next(), 0);
-        assertEquals(0, this.g.V().has(T.label, "Person").has("name", "marko").has(T.label, "Product").count().next(), 0);
-        assertEquals(0, this.g.V().has(T.label, "Product").has("name", "marko").has(T.label, "Person").count().next(), 0);
-        assertEquals(0, this.g.V().has(T.label, "Corporate").has("name", "marko").has(T.label, "Person").count().next(), 0);
-    }
-
-    @Test
     public void shouldNotGenerateVerticesOrEdgesForGraphVariables() {
         graph.tx().readWrite();
         graph.variables().set("namespace", "rdf-xml");
@@ -598,10 +350,10 @@ public class NativeNeo4jStructureTest extends AbstractNeo4jGremlinTest {
         a.property(VertexProperty.Cardinality.single, "name", "the marko", "acl", "private");
         tryCommit(graph, graph -> {
             assertEquals(2, g.V().count().next().intValue());
-             //assertEquals(1, a.properties("name").count().next().intValue());
-             //assertEquals(1, b.properties("name").count().next().intValue());
-             //assertEquals(1, b.properties("location").count().next().intValue());
-             assertEquals(0, g.E().count().next().intValue());
+            //assertEquals(1, a.properties("name").count().next().intValue());
+            //assertEquals(1, b.properties("name").count().next().intValue());
+            //assertEquals(1, b.properties("location").count().next().intValue());
+            assertEquals(0, g.E().count().next().intValue());
 
             assertEquals(3l, this.getBaseGraph().execute("MATCH n RETURN COUNT(n)", null).next().get("COUNT(n)"));
             assertEquals(1l, this.getBaseGraph().execute("MATCH (n)-[r]->(m) RETURN COUNT(r)", null).next().get("COUNT(r)"));
@@ -710,6 +462,25 @@ public class NativeNeo4jStructureTest extends AbstractNeo4jGremlinTest {
             assertEquals(2, IteratorUtils.count(vertex.getBaseVertex().labels().iterator()));
         });
 
+        assertEquals(Long.valueOf(0), g.V().has(T.label, "organism").count().next());
+        assertEquals(Long.valueOf(1), g.V().has(T.label, LabelP.of("organism")).count().next());
+        assertEquals(Long.valueOf(1), g.V().has(T.label, LabelP.of("animal")).count().next());
+
+        vertex.removeLabel("organism");
+        vertex.removeLabel("animal");
+        assertEquals(0, vertex.labels().size());
+        vertex.addLabel("organism-animal");
+        tryCommit(graph, graph -> {
+            assertEquals(Long.valueOf(0), g.V().has(T.label, LabelP.of("organism")).count().next());
+            assertEquals(Long.valueOf(0), g.V().has(T.label, LabelP.of("animal")).count().next());
+            assertEquals(Long.valueOf(0), g.V().map(Traverser::get).has(T.label, LabelP.of("organism")).count().next());
+            assertEquals(Long.valueOf(0), g.V().map(Traverser::get).has(T.label, LabelP.of("animal")).count().next());
+            //
+            assertEquals(Long.valueOf(1), g.V().has(T.label, LabelP.of("organism-animal")).count().next());
+            assertEquals(Long.valueOf(1), g.V().has(T.label, "organism-animal").count().next());
+            assertEquals(Long.valueOf(1), g.V().map(Traverser::get).has(T.label, LabelP.of("organism-animal")).count().next());
+            assertEquals(Long.valueOf(1), g.V().map(Traverser::get).has(T.label, "organism-animal").count().next());
+        });
     }
 
 }
\ No newline at end of file