|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.neo4j.index.impl.GenericIndexService
org.neo4j.index.lucene.LuceneIndexService
public class LuceneIndexService
An implementation of IndexService
which uses Lucene as backend.
Additional features to IndexService
is:
enableCache(String, int)
will enable a LRU cache for the
specific key and will boost performance in performance-critical areas.getNodes(String, Object, Sort)
where you can pass in a
Sort
option to control in which order Lucene returns the resultssetLazySearchResultThreshold(int)
will control the threshold for
when a search result is considered big enough to be returned as a lazy
iteration, making getNodes(String, Object)
return very fast, but
skips caching
Field Summary | |
---|---|
static int |
DEFAULT_LAZY_SEARCH_RESULT_THRESHOLD
The default value for getLazySearchResultThreshold() |
protected static String |
DIR_NAME
|
protected static String |
DOC_ID_KEY
|
protected static String |
DOC_INDEX_KEY
|
Constructor Summary | |
---|---|
LuceneIndexService(GraphDatabaseService graphDb)
|
Method Summary | |
---|---|
void |
enableCache(String key,
int maxNumberOfCachedEntries)
Enables an LRU cache for a specific index (specified by key ) so
that the maxNumberOfCachedEntries number of results found with
getNodes(String, Object) are cached for faster consecutive
lookups. |
protected org.apache.lucene.search.Query |
formQuery(String key,
Object value)
|
protected Class<? extends LuceneDataSource> |
getDataSourceClass()
|
protected String |
getDirName()
|
int |
getLazySearchResultThreshold()
Returns the threshold for when a result is considered big enough to skip cache and be returned as a fully lazy iterator so that getNodes(String, Object) will return very fast and all the
reading and fetching of nodes is done lazily before each step in the
iteration of the returned result. |
IndexHits<Node> |
getNodes(String key,
Object value)
Returns all nodes indexed with key and value . |
IndexHits<Node> |
getNodes(String key,
Object value,
org.apache.lucene.search.Sort sortingOrNull)
Just like getNodes(String, Object) , but with sorted result. |
Node |
getSingleNode(String key,
Object value)
Returns a single node indexed with associated with key and
value . |
protected byte[] |
getXaResourceId()
|
void |
index(Node node,
String key,
Object value)
Index node with key and value . |
protected void |
indexThisTx(Node node,
String key,
Object value)
|
protected Iterator<Node> |
instantiateIdToNodeIterator(Iterator<Long> ids)
|
protected void |
removeIndexThisTx(Node node,
String key,
Object value)
|
void |
setLazySearchResultThreshold(int numberOfHitsBeforeLazyLoading)
Sets the threshold for when a result is considered big enough to skip cache and be returned as a fully lazy iterator so that getNodes(String, Object) will return very fast and all the
reading and fetching of nodes is done lazily before each step in the
iteration of the returned result. |
void |
shutdown()
Stops this indexing service committing any asynchronous requests that are currently queued (see Isolation ). |
Methods inherited from class org.neo4j.index.impl.GenericIndexService |
---|
beginTx, getGraphDb, getQueue, removeIndex, setIsolation |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_LAZY_SEARCH_RESULT_THRESHOLD
getLazySearchResultThreshold()
protected static final String DOC_ID_KEY
protected static final String DOC_INDEX_KEY
protected static final String DIR_NAME
Constructor Detail |
---|
public LuceneIndexService(GraphDatabaseService graphDb)
graphDb
- the GraphDatabaseService
to use.Method Detail |
---|
protected Class<? extends LuceneDataSource> getDataSourceClass()
protected String getDirName()
protected byte[] getXaResourceId()
public void enableCache(String key, int maxNumberOfCachedEntries)
key
) so
that the maxNumberOfCachedEntries
number of results found with
getNodes(String, Object)
are cached for faster consecutive
lookups. It's preferred to enable cache at construction time.
key
- the index to enable cache for.maxNumberOfCachedEntries
- the max size of the cache before old ones
are flushed from the cache.public void setLazySearchResultThreshold(int numberOfHitsBeforeLazyLoading)
getNodes(String, Object)
will return very fast and all the
reading and fetching of nodes is done lazily before each step in the
iteration of the returned result. The default value is
DEFAULT_LAZY_SEARCH_RESULT_THRESHOLD
.
numberOfHitsBeforeLazyLoading
- the threshold where results which
are bigger than that threshold becomes lazy.public int getLazySearchResultThreshold()
getNodes(String, Object)
will return very fast and all the
reading and fetching of nodes is done lazily before each step in the
iteration of the returned result. The default value is
DEFAULT_LAZY_SEARCH_RESULT_THRESHOLD
.
public void index(Node node, String key, Object value)
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.
Note that this implementation will cast objects given as the value to
String
.
index
in interface IndexService
index
in class org.neo4j.index.impl.GenericIndexService
node
- node to indexkey
- the key in the key-value pair to associate with node
.value
- the value in the key-value pair to associate with node
.protected void indexThisTx(Node node, String key, Object value)
indexThisTx
in class org.neo4j.index.impl.GenericIndexService
public IndexHits<Node> getNodes(String key, Object value)
key
and value
.
Note that this implementation will cast objects given as the value to
String
.
key
- the key for indexvalue
- the value for index
public IndexHits<Node> getNodes(String key, Object value, org.apache.lucene.search.Sort sortingOrNull)
getNodes(String, Object)
, but with sorted result.
key
- the index to query.value
- the value to query for.sortingOrNull
- lucene sorting behaviour for the result. Ignored if
null
.
sortingOrNull
.protected Iterator<Node> instantiateIdToNodeIterator(Iterator<Long> ids)
protected org.apache.lucene.search.Query formQuery(String key, Object value)
public Node getSingleNode(String key, Object value)
IndexService
key
and
value
. If no such node exist null
is returned.
If more then one node is found a runtime exception is thrown.
key
- the key for indexvalue
- the value for index
null
protected void removeIndexThisTx(Node node, String key, Object value)
removeIndexThisTx
in class org.neo4j.index.impl.GenericIndexService
public void shutdown()
IndexService
Isolation
). After this method has been
invoked any following method invocation on this instance is invalid.
shutdown
in interface IndexService
shutdown
in class org.neo4j.index.impl.GenericIndexService
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |