Auto indexed keys missing

35 views
Skip to first unread message

vlg

unread,
Oct 5, 2012, 3:40:31 AM10/5/12
to ne...@googlegroups.com
Hello there,

I'm faced to an issue regarding auto-indexding in neo4j. When I create an automatic index (either at database creation, or afterward using the startAutoIndexProperty method), everything is fine. Now if I shutdown the database and reopen it, the keys seems not to be indexed anymore.

Here is a small snippet to illustrate this:

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.kernel.EmbeddedGraphDatabase;

public class Test
{
    public static void main(String [] args) {
        GraphDatabaseService graphDb = new GraphDatabaseFactory().
                newEmbeddedDatabaseBuilder( "C:\\NeoTest" ).
                setConfig( GraphDatabaseSettings.node_auto_indexing, "true" ).
                setConfig( GraphDatabaseSettings.node_keys_indexable, "ID" ).
                newGraphDatabase();
        
        System.out.println(graphDb.index().getNodeAutoIndexer().isEnabled());
        System.out.println(graphDb.index().getNodeAutoIndexer().getAutoIndexedProperties());
        
        graphDb.shutdown();
        
        // Reopen it
        graphDb = new EmbeddedGraphDatabase("C:\\NeoTest");
        
        // Keys are missing
        graphDb.index().getNodeAutoIndexer().setEnabled(true);
        System.out.println(graphDb.index().getNodeAutoIndexer().getAutoIndexedProperties());
        
        graphDb.shutdown();
    }
}

This gives me:
true
[ID]
[]
 
 Any idea ?

I'm using Neo4j 1.7.2 community on Windows 7.

Thanks in advance!

 

Michael Hunger

unread,
Oct 5, 2012, 3:45:42 AM10/5/12
to ne...@googlegroups.com
auto-index information is not persistet

you have to provide the same config to the db when you reopen it.

Michael

--
 
 

vlg

unread,
Oct 5, 2012, 5:09:24 AM10/5/12
to ne...@googlegroups.com
Thank you for your answer. 

I guess I've to maintain a file in the database directory containing all keys that are indexed.

Does Neo4j provides a conveinient way of doing this ? (except using a pseudo-node in which i'd store a property containing all indexed keys)

Vincent

Michael Hunger

unread,
Oct 5, 2012, 5:52:22 AM10/5/12
to ne...@googlegroups.com
That's what you usually use the neo4j.properties file for that you pass to the db at startup.


Michael

--
 
 

Reply all
Reply to author
Forward
0 new messages