Indexing in Spring Data Neo4j
Posted By : Abhay Garg | 12-Mar-2015
Indexing -> Indexing is used in Neo4j to quickly find nodes and relationships to start graph operations from Schema (Label based) Indexing .
STEP 1 Create Index -> You can use either of them
Using Cypher-> By using Cypher you can create index with this Cypher Query
CREATE INDEX ON :Person(name);
Using Spring Data Neo4j
import org.springframework.data.neo4j.annotation.Indexed
import org.springframework.data.neo4j.annotation.NodeEntity
@NodeEntit
class Person{
@Indexed
String name
}
So it creates schema Indexing on Person Domain at name property.
STEP 2 Use Index -> In cypher you can find Data like match (person:Person) where person.name="oodles" return person .
So now you can get data in O(1) , otherwise it will search on all Person Nodes.
Legacy Indexing in Neo4j -> The default index implementation is provided by the neo4j-lucene-index. So you can use lucene Query to get the Data .
STEP 1 Create Index -> In Spring Data Neo4j
import org.springframework.data.neo4j.support.index.IndexType
import org.springframework.data.neo4j.annotation.Indexed
import org.springframework.data.neo4j.annotation.NodeEntity
@NodeEntity
class Job{
@Indexed
String name
@Indexed(indexName = jobSearch, indexType=IndexType.FULLTEXT,numeric=false)
String publishDate
}
START jobWithDate=node:jobSearch("publishDate:[2015-03-18T18:30:00.000Z TO 2015-03-18T18:30:00.000Z]") match (jobWithDate) where jobWithDate.name="oodles" return jobWithDate.
For More information visit this link
THANKS
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Abhay Garg
Abhay is a Grails Developer expertise in OptaPlanner and Angular js framework.