org.neo4j.index.lucene
Class LuceneFulltextIndexService

java.lang.Object
  extended by org.neo4j.index.impl.GenericIndexService
      extended by org.neo4j.index.lucene.LuceneIndexService
          extended by org.neo4j.index.lucene.LuceneFulltextIndexService
All Implemented Interfaces:
IndexService
Direct Known Subclasses:
LuceneFulltextQueryIndexService

public class LuceneFulltextIndexService
extends LuceneIndexService

A LuceneIndexService which indexes the values with fulltext indexing. Fulltext means that the indexing process takes the values you throw in and tokenizes those into words so that you can query for those individual words in getNodes(String, Object). Also queries are case-insensitive. It stores more data per Lucene entry to make this possible. This makes it incompatible with LuceneIndexService so it has got its own XA resource ID. This means that you can have one LuceneIndexService and one LuceneFulltextIndexService for a GraphDatabaseService. See more information at http://wiki.neo4j.org/content/Indexing_with_IndexService#Fulltext_indexing


Field Summary
protected static String DOC_INDEX_SOURCE_KEY
           
protected static String FULLTEXT_DIR_NAME_POSTFIX
           
 
Fields inherited from class org.neo4j.index.lucene.LuceneIndexService
DEFAULT_LAZY_SEARCH_RESULT_THRESHOLD, DIR_NAME, DOC_ID_KEY, DOC_INDEX_KEY
 
Constructor Summary
LuceneFulltextIndexService(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 LuceneIndexService.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()
           
 IndexHits<Node> getNodes(String key, Object value)
          Since this is a "fulltext" index it changes the contract of this method slightly.
protected  byte[] getXaResourceId()
           
 
Methods inherited from class org.neo4j.index.lucene.LuceneIndexService
getLazySearchResultThreshold, getNodes, getSingleNode, index, indexThisTx, instantiateIdToNodeIterator, removeIndexThisTx, setLazySearchResultThreshold, shutdown
 
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

DOC_INDEX_SOURCE_KEY

protected static final String DOC_INDEX_SOURCE_KEY
See Also:
Constant Field Values

FULLTEXT_DIR_NAME_POSTFIX

protected static final String FULLTEXT_DIR_NAME_POSTFIX
See Also:
Constant Field Values
Constructor Detail

LuceneFulltextIndexService

public LuceneFulltextIndexService(GraphDatabaseService graphDb)
Parameters:
graphDb - the GraphDatabaseService to use.
Method Detail

getDataSourceClass

protected Class<? extends LuceneDataSource> getDataSourceClass()
Overrides:
getDataSourceClass in class LuceneIndexService

getDirName

protected String getDirName()
Overrides:
getDirName in class LuceneIndexService

getXaResourceId

protected byte[] getXaResourceId()
Overrides:
getXaResourceId in class LuceneIndexService

getNodes

public IndexHits<Node> getNodes(String key,
                                Object value)
Since this is a "fulltext" index it changes the contract of this method slightly. It treats the value more like a query in than you can query for individual words in your indexed values. So if you've indexed node (1) with value "Andy Wachowski" and node (2) with "Larry Wachowski" you can expect this behaviour if you query for:

Specified by:
getNodes in interface IndexService
Overrides:
getNodes in class LuceneIndexService
Parameters:
key - the key for index
value - the value for index
Returns:
nodes that have been indexed with key and value

formQuery

protected org.apache.lucene.search.Query formQuery(String key,
                                                   Object value)
Overrides:
formQuery in class LuceneIndexService

enableCache

public void enableCache(String key,
                        int maxNumberOfCachedEntries)
Description copied from class: LuceneIndexService
Enables an LRU cache for a specific index (specified by key) so that the maxNumberOfCachedEntries number of results found with LuceneIndexService.getNodes(String, Object) are cached for faster consecutive lookups. It's preferred to enable cache at construction time.

Overrides:
enableCache in class LuceneIndexService
Parameters:
key - the index to enable cache for.
maxNumberOfCachedEntries - the max size of the cache before old ones are flushed from the cache.


Copyright © 2010 Neo4j. All Rights Reserved.