private void removeFromIndexes(Relationship relationship) {
     final IndexManager indexManager = delegate.index();
     for (String indexName : indexManager.relationshipIndexNames()) {
         RelationshipIndex relationshipIndex = indexManager.forRelationships(indexName);
         if (relationshipIndex.isWriteable()) relationshipIndex.remove(relationship);
     }
 }
 private void removeFromIndexes(Node node) {
     final IndexManager indexManager = delegate.index();
     for (String indexName : indexManager.nodeIndexNames()) {
         Index<Node> nodeIndex = indexManager.forNodes(indexName);
         if (nodeIndex.isWriteable()) nodeIndex.remove(node);
     }
 }
 @SuppressWarnings("unchecked")
 @Override
 public <T extends PropertyContainer> Index<T> getIndex(String indexName) {
     IndexManager indexManager = delegate.index();
     if (indexManager.existsForNodes(indexName)) return (Index<T>) indexManager.forNodes(indexName);
     if (indexManager.existsForRelationships(indexName)) return (Index<T>) indexManager.forRelationships(indexName);
     throw new NoSuchIndexException(indexName);
 }
 // TODO handle existing indexes
 @SuppressWarnings("unchecked")
 @Override
 public <T extends PropertyContainer> Index<T> createIndex(Class<T> type, String indexName, IndexType indexType) {
     Transaction tx = delegate.beginTx();
     try {
         IndexManager indexManager = delegate.index();
         if (isNode(type)) {
             if (indexManager.existsForNodes(indexName))
                 return (Index<T>) checkAndGetExistingIndex(indexName, indexType, indexManager.forNodes(indexName));
             Index<Node> index = indexManager.forNodes(indexName, indexConfigFor(indexType));
             return (Index<T>) index;
         } else {
             if (indexManager.existsForRelationships(indexName))
                 return (Index<T>) checkAndGetExistingIndex(indexName, indexType, indexManager.forRelationships(indexName));
             return (Index<T>) indexManager.forRelationships(indexName, indexConfigFor(indexType));
         }
     } finally {
         tx.success();tx.close();
     }
 }
 private <T extends PropertyContainer> Index<T> checkAndGetExistingIndex(final String indexName, IndexType indexType, final Index<T> index) {
     Map<String, String> existingConfig = delegate.index().getConfiguration(index);
     Map<String, String> config = indexConfigFor(indexType);
     if (configCheck(config, existingConfig, "provider") && configCheck(config, existingConfig, "type")) return index;
     throw new IllegalArgumentException("Setup for index "+indexName+" does not match. Existing: "+existingConfig+" required "+config);
  }