Database Reference
In-Depth Information
Writing data in legacy indexing
We briefly touched upon the history of schema and legacy indexing in the last chapter un-
der the Schema and legacy indexing section.
Let's quickly recap important aspects of schema and legacy indexing:
• Schema was introduced in Neo4j 2.0, where it provides the feature of creating in-
dexes and constraints on the properties of nodes within a label scope
• Once schema is defined on a label, it will automatically be used by the Cypher
query planner
• In legacy / manual indexing, users need to manually create/update/delete the in-
dexes
• Searching legacy indexes is also a manual process where users need to provide the
code for searching the indexes for faster retrieval
• Legacy indexes are still supported, but it is just to provide backward compatibility
for Neo4j applications that are developed and are running on Neo4j 1.9.9 or earlier
Further in this chapter, we will see how writes and searches are performed in legacy in-
dexes and schema.
Legacy indexes can be created and managed by using the Java APIs exposed by Neo4j.
Let's see the usage and syntax of Java APIs for managing legacy indexes.
The following is a piece of Java code that creates two manual indexes each on nodes and
relationships:
import org.neo4j.graphdb.*;
import org.neo4j.graphdb.factory.*;
import org.neo4j.graphdb.index.*;
public class CreateOrUpdateLegacyIndexes {
public static void main(String[] args) {
new CreateOrUpdateLegacyIndexes().addDataToNodeIndex();
}
public void addDataToNodeIndex() {
String DBLocation = "$Neo4J_HOME/data/graph.db";
Search WWH ::




Custom Search