mgmt.buildIndex("index2", Vertex.class).indexOnly(event). addKey(text, getTextMapping()).buildMixedIndex(INDEX);
@Test public void testIndexQueryWithLabelsAndContainsIN() { // This test is based on the steps to reproduce #882 String labelName = "labelName"; VertexLabel label = mgmt.makeVertexLabel(labelName).make(); PropertyKey uid = mgmt.makePropertyKey("uid").dataType(String.class).make(); JanusGraphIndex uidCompositeIndex = mgmt.buildIndex("uidIndex", Vertex.class) .indexOnly(label).addKey(uid).unique().buildCompositeIndex(); mgmt.setConsistency(uidCompositeIndex, ConsistencyModifier.LOCK); finishSchema(); JanusGraphVertex foo = graph.addVertex(labelName); JanusGraphVertex bar = graph.addVertex(labelName); foo.property("uid", "foo"); bar.property("uid", "bar"); graph.tx().commit(); Iterable<JanusGraphVertex> vertexes = graph.query() .has("uid", Contain.IN, ImmutableList.of("foo", "bar")) .has(LABEL_NAME, labelName) .vertices(); assertEquals(2, Iterables.size(vertexes)); for (JanusGraphVertex v : vertexes) { assertEquals(labelName, v.vertexLabel().name()); } }
mgmt.buildIndex("index2", Edge.class).indexOnly(label). addKey(text, getTextMapping()).buildMixedIndex(INDEX);
/** * Create both <i>posts</i> and <i>follows</i> edges and related index. * <br/> * * Because the property and index for both follows and posts is the same we create them at the same point here. */ private void createEdgeSchema() { LOGGER.info("create edges schema"); EdgeLabel posts = mgt.makeEdgeLabel(POSTS).make(); EdgeLabel follows = mgt.makeEdgeLabel(FOLLOWS).make(); PropertyKey createdAt = mgt.makePropertyKey(CREATED_AT).dataType(Long.class).make(); mgt.buildIndex(indexName(POSTS, CREATED_AT), Edge.class). addKey(createdAt). indexOnly(posts). buildMixedIndex(BACKING_INDEX); mgt.buildIndex(indexName(FOLLOWS, CREATED_AT), Edge.class). addKey(createdAt). indexOnly(follows). buildMixedIndex(BACKING_INDEX); }
/** * Create the user schema - vertex label, property and index. */ private void createUserSchema(){ LOGGER.info("Create {} schema", USER); VertexLabel user = mgt.makeVertexLabel(USER).make(); PropertyKey userName = mgt.makePropertyKey(USER_NAME).dataType(String.class).make(); mgt.buildIndex(indexName(USER, USER_NAME), Vertex.class). addKey(userName, Mapping.STRING.asParameter()). indexOnly(user). buildMixedIndex(BACKING_INDEX); }
/** * Create the statusUpdate schema - vertex label, property and full-text index. */ private void createStatusUpdateSchema(){ LOGGER.info("Create {} schema", STATUS_UPDATE); VertexLabel statusUpdate = mgt.makeVertexLabel(STATUS_UPDATE).make(); PropertyKey content = mgt.makePropertyKey(CONTENT).dataType(String.class).make(); mgt.buildIndex(indexName(STATUS_UPDATE, CONTENT), Vertex.class). addKey(content, Mapping.TEXTSTRING.asParameter()). indexOnly(statusUpdate). buildMixedIndex(BACKING_INDEX); }
.indexOnly(connect).addKey(text).buildCompositeIndex(); .indexOnly(person).unique().buildCompositeIndex(); JanusGraphIndex vertex12 = mgmt.buildIndex("vertex12", Vertex.class).addKey(text) .indexOnly(person).buildCompositeIndex(); JanusGraphIndex vertex2 = mgmt.buildIndex("vertex2", Vertex.class).addKey(time).addKey(name) .indexOnly(organization).buildCompositeIndex(); JanusGraphIndex vertex3 = mgmt.buildIndex("vertex3", Vertex.class).addKey(name).buildCompositeIndex();
JanusGraphIndex index2 = mgmt.buildIndex("index2", Vertex.class).indexOnly(person). addKey(text, getTextMapping()).addKey(weight).buildMixedIndex(INDEX); JanusGraphIndex index3 = mgmt.buildIndex("index3", Vertex.class).indexOnly(org). addKey(text, getTextMapping()).addKey(weight).buildMixedIndex(INDEX);
.dataType(Integer.class).make(); management.buildIndex("artistByName", Vertex.class).addKey(name).indexOnly(artist) .buildCompositeIndex(); management.buildIndex("songByName", Vertex.class).addKey(name).indexOnly(song) .buildCompositeIndex(); management.buildIndex("songByType", Vertex.class).addKey(songType).indexOnly(song) .buildCompositeIndex(); management.buildIndex("songByPerformances", Vertex.class).addKey(performances).indexOnly(song) .buildCompositeIndex(); .dataType(Integer.class).make(); management.buildIndex("personByName", Vertex.class).addKey(name).indexOnly(person) .buildCompositeIndex(); management.buildIndex("softwareByName", Vertex.class).addKey(name).indexOnly(software) .buildCompositeIndex(); management.buildIndex("personByAge", Vertex.class).addKey(age).indexOnly(person) .buildCompositeIndex(); management.buildIndex("softwareByLang", Vertex.class).addKey(lang).indexOnly(software) .buildCompositeIndex();
.addKey(time).indexOnly(person).unique().buildCompositeIndex(); final JanusGraphIndex vertexIndex2 = mgmt.buildIndex("vindex2", Vertex.class) .addKey(time).addKey(text).unique().buildCompositeIndex();
@Test public void testIndexShouldNotBeEnabledForExistingPropertyKeyAndConstrainedToExistingEdgeLabel() { mgmt.makePropertyKey("alreadyExistingProperty").dataType(String.class).cardinality(Cardinality.SINGLE).make(); mgmt.makeEdgeLabel("alreadyExistingLabel").make(); finishSchema(); PropertyKey existingPropertyKey = mgmt.getPropertyKey("alreadyExistingProperty"); EdgeLabel existingLabel = mgmt.getEdgeLabel("alreadyExistingLabel"); mgmt.buildIndex("newIndex", Edge.class).addKey(existingPropertyKey).indexOnly(existingLabel).buildCompositeIndex(); finishSchema(); assertNotEquals(SchemaStatus.ENABLED, mgmt.getGraphIndex("newIndex").getIndexStatus(existingPropertyKey)); }
@Test public void testIndexShouldNotBeEnabledForExistingPropertyKeyAndConstrainedToExistingVertexLabel() { mgmt.makePropertyKey("alreadyExistingProperty").dataType(String.class).cardinality(Cardinality.SINGLE).make(); mgmt.makeVertexLabel("alreadyExistingLabel").make(); finishSchema(); PropertyKey existingPropertyKey = mgmt.getPropertyKey("alreadyExistingProperty"); VertexLabel existingLabel = mgmt.getVertexLabel("alreadyExistingLabel"); mgmt.buildIndex("newIndex", Vertex.class).addKey(existingPropertyKey).indexOnly(existingLabel).buildCompositeIndex(); finishSchema(); assertNotEquals(SchemaStatus.ENABLED, mgmt.getGraphIndex("newIndex").getIndexStatus(existingPropertyKey)); }
@Test public void testIndexShouldBeEnabledForExistingPropertyKeyAndConstrainedToNewEdgeLabel() { mgmt.makePropertyKey("alreadyExistingProperty").dataType(String.class).cardinality(Cardinality.SINGLE).make(); finishSchema(); PropertyKey existingPropertyKey = mgmt.getPropertyKey("alreadyExistingProperty"); EdgeLabel newLabel = mgmt.makeEdgeLabel("newLabel").make(); mgmt.buildIndex("newIndex", Edge.class).addKey(existingPropertyKey).indexOnly(newLabel).buildCompositeIndex(); finishSchema(); assertEquals(SchemaStatus.ENABLED, mgmt.getGraphIndex("newIndex").getIndexStatus(existingPropertyKey)); }
@Test public void testIndexShouldBeEnabledForExistingPropertyKeyAndConstrainedToNewVertexLabel() { mgmt.makePropertyKey("alreadyExistingProperty").dataType(String.class).cardinality(Cardinality.SINGLE).make(); finishSchema(); PropertyKey existingPropertyKey = mgmt.getPropertyKey("alreadyExistingProperty"); VertexLabel newLabel = mgmt.makeVertexLabel("newLabel").make(); mgmt.buildIndex("newIndex", Vertex.class).addKey(existingPropertyKey).indexOnly(newLabel).buildCompositeIndex(); finishSchema(); assertEquals(SchemaStatus.ENABLED, mgmt.getGraphIndex("newIndex").getIndexStatus(existingPropertyKey)); }