Database Reference
In-Depth Information
//Search the ActorsIndex for more than one property
hits = actorsIndex.query("Name","*a*");
Node searchNode1 = hits.next();
System.out.println("Node ID = "+searchNode1.getId()+", Name
= "+searchNode1.getProperty("Name"));
And we are done!!!
For compiling and running the preceding code snippets, perform the following steps and
execute it from IDE itself:
1. Stop your Neo4j server (if it is already running).
2. Initialize the Java variable
DBLocation
with the location of your Neo4j data-
base as per your local filesystem, which is generally available at
<$NEO4J_HOME>/data/graph.db
.
3. Provide all JAR files from
<$NEO4J_HOME>/lib/
in the classpath.
4. Compile and execute the preceding code.
For deleting and removing indexes, you need to invoke the
delete()
and
remove()
methods of
org.neo4j.graphdb.index.Index
.
Note
There is no operation for updating the index entries. First, the index entries need to be re-
moved and added again to perform the update operations.
Neo4j also provides options to manage the behavior of the indexes. We can create a full
text search index or case-insensitive search index:
//Creating and initializing Full text Search Index
Index<Node> indexFullText = graphDb.index().forNodes(
"full_text_search_index",MapUtil.stringMap(
IndexManager.PROVIDER, "lucene", "type", "fulltext" ));
//Creating and initializing an exact search index, which is
case insensitive.
Index<Node> indexCaseInSensitive =
graphDb.index().forNodes(
"exact-case-insensitive",MapUtil.stringMap( "type",
"exact", "to_lower_case", "true" ) );