First you need to do this in the new database. An automatic index is created lazily, which means that it is not created until first access. You have before first access to complete this configuration. If you try to change a property after it is created, it will not work. So, the first step is to load the database with automatic indexing enabled (node ββor relationships).
val db = new GraphDatabaseFactory().newEmbedddedDatabaseBuilder("path/to/db"). setConfig(GraphDatabaseSettings.node_keys_indexable, "label,username"). setConfig(GraphDatabaseSettings.node_auto_indexing, "true").newGraphDatabase()
Now, before you do anything, you must set the configuration properties. You can find out about the possible properties and values here . For this we need only two lines.
val autoIndex = db.index.forNodes("node_auto_index") db.index.setConfiguration(autoIndex, "type", "fulltext")
And all this to him. Now you can create vertices and relationships, and an automatic index will be created and populated. You can use the following code to query using Lucene query .
autoIndex.getAutoIndex.query("label:*caseinsensitive*")
source share