Package org.neo4j.graphdb.index

Examples of org.neo4j.graphdb.index.IndexManager


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


        }
        return primitive;
    }

    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);
        }
    }
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

        graphDb = new EmbeddedGraphDatabase( "target/graphdb" );
        Transaction transaction = graphDb.beginTx();
        try
        {
            // START SNIPPET: createIndices
            IndexManager index = graphDb.index();
            Index<Node> actors = index.forNodes( "actors" );
            Index<Node> movies = index.forNodes( "movies" );
            RelationshipIndex roles = index.forRelationships( "roles" );
            // END SNIPPET: createIndices

            // START SNIPPET: createNodes
            // Actors
            Node reeves = graphDb.createNode();
View Full Code Here

    @Test
    public void checkIfIndexExists()
    {
        // START SNIPPET: checkIfExists
        IndexManager index = graphDb.index();
        boolean indexExists = index.existsForNodes( "actors" );
        // END SNIPPET: checkIfExists
        assertTrue( indexExists );
    }
View Full Code Here

        GraphDatabaseService graphDb = new EmbeddedGraphDatabase( "target/graphdb-delete" );
        Transaction transaction = graphDb.beginTx();
        try
        {
            // START SNIPPET: delete
            IndexManager index = graphDb.index();
            Index<Node> actors = index.forNodes( "actors" );
            actors.delete();
            // END SNIPPET: delete
            transaction.success();
        }
        finally
View Full Code Here

    }

    @Test
    public void removeFromIndex()
    {
        IndexManager index = graphDb.index();
        Index<Node> actors = index.forNodes( "actors" );
        Node bellucci = actors.get( "name", "Monica Bellucci" ).getSingle();
        assertNotNull( bellucci );

        // START SNIPPET: removeNodeFromIndex
        // completely remove bellucci from the actors index
View Full Code Here

    }

    @Test
    public void update()
    {
        IndexManager index = graphDb.index();
        Index<Node> actors = index.forNodes( "actors" );

        // START SNIPPET: update
        // create a node with a property
        Node fishburn = graphDb.createNode();
        fishburn.setProperty( "name", "Fishburn" );
View Full Code Here

    }

    @Test
    public void doQueriesForNodes()
    {
        IndexManager index = graphDb.index();
        Index<Node> actors = index.forNodes( "actors" );
        Index<Node> movies = index.forNodes( "movies" );
        Set<String> found = new HashSet<String>();
        @SuppressWarnings( "serial" ) Set<String> expectedActors = new HashSet<String>()
        {
            {
                add( "Monica Bellucci" );
View Full Code Here

    }

    @Test
    public void doQueriesForRelationships()
    {
        IndexManager index = graphDb.index();
        RelationshipIndex roles = index.forRelationships( "roles" );
        Index<Node> actors = graphDb.index().forNodes( "actors" );
        Index<Node> movies = index.forNodes( "movies" );

        Node reeves = actors.get( "name", "Keanu Reeves" ).getSingle();
        Node theMatrix = movies.get( "title", "The Matrix" ).getSingle();

        // START SNIPPET: queryForRelationships
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.