Search code examples
neo4jluceneluke

In Neo4j (using Lucene index) how can I find what a Node has been indexed under?


For a given index and key, I can look up Nodes using (Cypher):

START n=node:index('key:*')
RETURN n

Or using (Embedded Java):

Index<Node> index = .....
IndexHits<Node> hits = index.query(key, query);
Iterator<Node> itr = hits.iterator();

What I'm looking for is a way to do this in reverse; to find key/value pairs for which a given Node has been indexed. Something like:

Map<String, Object> pairs = index.getKeyValuePairs(node);

The only tool I've been able to find which goes in this direction is Luke, but this is a desktop Java app, making it tricky to use on indexes which are on a server.

The reason I'm interested in this is because I've got a large neo4j dataset where I've mis-indexed some Nodes. Now I can't find them without using a wildcard index query which is too imprecise and requires iteration of the returned IndexHits, or using a Cypher query WHERE clause, which is too slow.


Solution

  • In Neo4j 1.9 you can't. In Neo4j 2.0, you can get the Labels and Indexes on a node, e.g.

    CREATE n:Person{name:'Jim'}
    

    Make an index

    CREATE INDEX on :Person(name)
    

    List labels

    MATCH n
    RETURN LABELS(n)