Debajyoti Roy
Debajyoti Roy

Reputation: 995

How to use index in neo4j 2.0 for like search?

We have an index on first name of patients

CREATE INDEX ON :Patient(FIRST_NAME)

One of our services finds patients whose name starts with say XYZ(case insensitive):

match (n:Patient) where n.FIRST_NAME=~'(?i)XYZ.*' return n

We have billions of Patient nodes. I am not sure if the index is used at all for this.

Is there a way to leverage the Lucene index and execute this any faster ? We are open to using Java API for this too.

Upvotes: 1

Views: 395

Answers (1)

Eve Freeman
Eve Freeman

Reputation: 33145

The index would not be used for that, yet. Currently, the new label-based indexes can only do exact lookups. You could still use a legacy index or a legacy auto-index, and use the START clause to do this sort of thing, with the full-text style lucene syntax, instead of regex. If you're using REST, see an example to create an automatic node full-text index here:

http://docs.neo4j.org/chunked/milestone/rest-api-configurable-auto-indexes.html#rest-api-create-an-auto-index-for-nodes-with-specific-configuration

Upvotes: 2

Related Questions