Chris Beach
Chris Beach

Reputation: 4392

How to programmatically query Neo4J auto index (as opposed to legacy index)

I have a numeric auto index defined:

val db = new GraphDatabaseFactory()
  .newEmbeddedDatabaseBuilder(dbPath.getAbsolutePath)
  .newGraphDatabase()

neo.schema.indexFor(USER_LABEL).on(PROP_CURSOR).create()

I'd like this index to be used for numeric queries (I'm interested in nodes with the lowest "cursor" property). However, I can't find how best to do this in the API documentation. Any suggestions?

I'd prefer to avoid legacy Neo4J indexes as they're cumbersome to maintain, and I couldn't find a way to update a value in a legacy index.

Upvotes: 1

Views: 168

Answers (1)

Chris Leishman
Chris Leishman

Reputation: 1798

You can use the GraphDatabaseService#findNodesByLabelAndProperty method (available on your db val).

There's good documentation example of this here: http://neo4j.com/docs/stable/tutorials-java-embedded-new-index.html

Upvotes: 1

Related Questions