abhaygarg12493
abhaygarg12493

Reputation: 1605

Regular Expression in Neo4j Cypher

We are using Neo4j Database using Spring Data Neo4j . Now we have a lot of cypher query in which we use Regular Expression , right now we are in development mode so we have only 2000 nodes in our database , Does it affects the performance if Neo4j Database have millions of node ???? Is there any way to get rid out from it ? Or we have to make such type of cypher in which we have no regex ?

Upvotes: 1

Views: 1069

Answers (2)

Michael Hunger
Michael Hunger

Reputation: 41676

In one of the next versions, Neo4j will support indexes for LIKE operations. Probably not for regexp expressions.

You can use the manual lucene fulltext index for such queries, just annotate your field with

@Index(type=FULLTEXT, indexName="search") String description;

And then you can use the query syntax in the START clause.

See here: http://neo4j.com/docs/stable/query-start.html#_get_node_or_relationship_from_index

START n=node:search("description:keyword")
RETURN n

See also: http://jexp.de/blog/2014/03/full-text-indexing-fts-in-neo4j-2-0/

Upvotes: 1

Brian Underwood
Brian Underwood

Reputation: 10856

Neo4j won't use indexes for regular expressions, so that would definitely affect your query performance as you grow.

Could you some examples of regular expressions? There might be a be another way to go about it.

Depending on your regular expressions, you might be able to duplicate the functionality with legacy indexes. Alternatively you could use an external tools like elasticsearch to support full-text searching

Upvotes: 3

Related Questions