org.neo4j.index
Interface IndexService

All Known Implementing Classes:
org.neo4j.index.impl.GenericIndexService, LuceneFulltextIndexService, LuceneFulltextQueryIndexService, LuceneIndexService, LuceneReadOnlyIndexService, RemoteIndexService

public interface IndexService

Index service to index nodes with a key and a value. The Neo4j Kernel has no indexing features built-in. Instead you'll have to manage indexing manually. IndexService is a means of providing those indexing capabilities for a Neo4j graph and integrate it as tightly as possible with the graph engine.

Note that changes on Node properties respective nodes that are deleted must be propagated to the index by the application.

See more at The Neo4j wiki page on "Indexing with IndexService".


Method Summary
 IndexHits<Node> getNodes(String key, Object value)
          Returns all nodes indexed with key and value.
 Node getSingleNode(String key, Object value)
          Returns a single node indexed with associated with key and value.
 void index(Node node, String key, Object value)
          Index node with key and value.
 void removeIndex(Node node, String key, Object value)
          Dissociates a key-value pair from node.
 void setIsolation(Isolation level)
          Changes isolation level for the running transaction.
 void shutdown()
          Stops this indexing service committing any asynchronous requests that are currently queued (see Isolation).
 

Method Detail

index

void index(Node node,
           String key,
           Object value)
Index node with key and value. A node can be associated with any number of key-value pairs.

Note about updating an index: If you've indexed a value from a property on a Node and that value gets updated, you'll have to remove the old value in addition to indexing the new value, else both values (the new and the old) will be indexed for that node.

When deleting a Node, application should remove the index entries for the node as well, to keep the index consistent with the node space.

Parameters:
node - node to index
key - the key in the key-value pair to associate with node.
value - the value in the key-value pair to associate with node.

getSingleNode

Node getSingleNode(String key,
                   Object value)
Returns a single node indexed with associated with key and value. If no such node exist null is returned. If more then one node is found a runtime exception is thrown.

Parameters:
key - the key for index
value - the value for index
Returns:
node that has been indexed with key and value or null

getNodes

IndexHits<Node> getNodes(String key,
                         Object value)
Returns all nodes indexed with key and value.

Parameters:
key - the key for index
value - the value for index
Returns:
nodes that have been indexed with key and value

removeIndex

void removeIndex(Node node,
                 String key,
                 Object value)
Dissociates a key-value pair from node. If no such association exist this method silently returns.

Parameters:
node - the node to dissociate from the key-value pair.
key - the key in the key-value pair.
value - the value in the key-value pair.

setIsolation

void setIsolation(Isolation level)
Changes isolation level for the running transaction. This method must be invoked before any index (index(Node, String, Object), removeIndex(Node, String, Object)) has been performed in the current transaction. The default isolation level is Isolation.SAME_TX . The isolation level is thread confined.

Parameters:
level - new isolation level

shutdown

void shutdown()
Stops this indexing service committing any asynchronous requests that are currently queued (see Isolation). After this method has been invoked any following method invocation on this instance is invalid.



Copyright © 2010 Neo4j. All Rights Reserved.