Schemas { private Boolean indexExists(String labelName, List<String> propertyNames) { Schema schema = tx.schema(); for (IndexDefinition indexDefinition : Iterables.asList(schema.getIndexes(Label.label(labelName)))) { List<String> properties = Iterables.asList(indexDefinition.getPropertyKeys()); if (properties.equals(propertyNames)) { return true; } } return false; }  @Procedure(value = "apoc.schema.assert", mode = Mode.SCHEMA) @Description("apoc.schema.assert({indexLabel:[[indexKeys]], ...}, {constraintLabel:[constraintKeys], ...}, dropExisting : true) yield label, key, keys, unique, action - drops all other existing indexes and constraints when `dropExisting` is `true` (default is `true`), and asserts that at the end of the operation the given indexes and unique constraints are there, each label:key pair is considered one constraint/label. Non-constraint indexes can define compound indexes with label:[key1,key2...] pairings.") Stream<AssertSchemaResult> schemaAssert(@Name("indexes") Map<String, List<Object>> indexes, @Name("constraints") Map<String, List<Object>> constraints, @Name(value = "dropExisting", defaultValue = "true") boolean dropExisting); @Procedure(value = "apoc.schema.nodes", mode = Mode.SCHEMA) @Description("CALL apoc.schema.nodes([config]) yield name, label, properties, status, type") Stream<IndexConstraintNodeInfo> nodes(@Name(value = "config",defaultValue = "{}") Map<String,Object> config); @Procedure(value = "apoc.schema.relationships", mode = Mode.SCHEMA) @Description("CALL apoc.schema.relationships([config]) yield name, startLabel, type, endLabel, properties, status") Stream<ConstraintRelationshipInfo> relationships(@Name(value = "config",defaultValue = "{}") Map<String,Object> config); @UserFunction(value = "apoc.schema.node.indexExists") @Description("RETURN apoc.schema.node.indexExists(labelName, propertyNames)") Boolean indexExistsOnNode(@Name("labelName") String labelName, @Name("propertyName") List<String> propertyNames); @UserFunction(value = "apoc.schema.node.constraintExists") @Description("RETURN apoc.schema.node.constraintExists(labelName, propertyNames)") Boolean constraintExistsOnNode(@Name("labelName") String labelName, @Name("propertyName") List<String> propertyNames); @UserFunction(value = "apoc.schema.relationship.constraintExists") @Description("RETURN apoc.schema.relationship.constraintExists(type, propertyNames)") Boolean constraintExistsOnRelationship(@Name("type") String type, @Name("propertyName") List<String> propertyNames); List<AssertSchemaResult> assertConstraints(Map<String, List<Object>> constraints0, boolean dropExisting); List<AssertSchemaResult> assertIndexes(Map<String, List<Object>> indexes0, boolean dropExisting); @Context
    public GraphDatabaseService db; @Context
    public Transaction tx; @Context
    public KernelTransaction ktx; }
@Test public void testIndexExists() { db.executeTransactionally("CREATE INDEX ON :Foo(bar)"); testResult(db, "RETURN apoc.schema.node.indexExists('Foo', ['bar'])", (result) -> { Map<String, Object> r = result.next(); assertEquals(true, r.entrySet().iterator().next().getValue()); }); }