Package org.neo4j.graphdb.index

Examples of org.neo4j.graphdb.index.IndexManager


        assertTrue(index.existsForNodes("heroes"));
      }
   
    @Test
      public void useTrinityIndex() throws Exception {
        IndexManager index = getRestGraphDb().index();            
        Index<Node> goodGuys = index.forNodes("heroes");
        IndexHits<Node> hits = goodGuys.get( "name", "Trinity" );
        Node trinity = hits.getSingle();
        assertEquals( "Trinity", trinity.getProperty("name") );
      }
View Full Code Here


        assertEquals( "Trinity", trinity.getProperty("name") );
      }
     
      @Test
      public void useMorpheusQuery() throws Exception {
        IndexManager index = getRestGraphDb().index();            
        Index<Node> goodGuys = index.forNodes("heroes");
        for (Node morpheus : goodGuys.query("name", "Morpheus")){
          assertEquals( "Morpheus", morpheus.getProperty("name") );
        }
      }
View Full Code Here

           }

          
           @Test
           public void checkForIndex() throws Exception {
               IndexManager index = graphDb.index();
               assertTrue(index.existsForNodes("heroes"));
           }
View Full Code Here

               assertEquals( "Heroes Collection", heroesCollectionNode.getProperty("type") );
           }
          
           @Test
           public void useMorpheusQuery() throws Exception {
             IndexManager index = graphDb.index();            
             Index<Node> goodGuys = index.forNodes("heroes");
             for (Node morpheus : goodGuys.query("name", "Morpheus")){
               assertEquals( "Morpheus", morpheus.getProperty("name") );
             }
           }
View Full Code Here

             }
           }
          
           @Test
           public void useTrinityIndex() throws Exception {
             IndexManager index = graphDb.index();            
             Index<Node> goodGuys = index.forNodes("heroes");
             IndexHits<Node> hits = goodGuys.get( "name", "Trinity" );
             Node trinity = hits.getSingle();
             assertEquals( "Trinity", trinity.getProperty("name") );
           }
View Full Code Here

             assertEquals( "Trinity", trinity.getProperty("name") );
           }
          
           @Test
           public void compareIndexAndTraversal() throws Exception {
             IndexManager index = graphDb.index();            
             Index<Node> goodGuys = index.forNodes("heroes");
             IndexHits<Node> hits = goodGuys.query( "name", "*" );           
             Traverser heroesTraverser = getHeroes();              
               assertEquals( heroesTraverser.nodes().iterator().next().getId(), hits.iterator().next().getId() );
           }
View Full Code Here

        result.put("relationships", relationships);

    }

    private void clearIndex(Map<String, Object> result) {
        IndexManager indexManager = graph.index();
        result.put("node-indexes", Arrays.asList(indexManager.nodeIndexNames()));
        result.put("relationship-indexes", Arrays.asList(indexManager.relationshipIndexNames()));
        for (String ix : indexManager.nodeIndexNames()) {
            indexManager.forNodes(ix).delete();
        }
        for (String ix : indexManager.relationshipIndexNames()) {
            indexManager.forRelationships(ix).delete();
        }
    }
View Full Code Here

            }
        }
    }

    private static void clearIndex(GraphDatabaseService gds) {
        IndexManager indexManager = gds.index();
        for (String ix : indexManager.nodeIndexNames()) {
            try {
                Index<Node> nodeIndex = indexManager.forNodes(ix);
                if (nodeIndex.isWriteable()) nodeIndex.delete();
            } catch(Exception e) {
                log.warn("Cannot delete node index "+ix+" "+e.getMessage());
            }
        }
        for (String ix : indexManager.relationshipIndexNames()) {
            try {
                RelationshipIndex relationshipIndex = indexManager.forRelationships(ix);
                if (relationshipIndex.isWriteable()) relationshipIndex.delete();
            } catch(Exception e) {
                log.warn("Cannot delete relationship index "+ix+" "+e.getMessage());
            }
        }
View Full Code Here

            if (nodeIndex.isWriteable()) nodeIndex.remove(node);
        }
    }

    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);
        }
    }
View Full Code Here

    }

    @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);
    }
View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.index.IndexManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.