|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jackrabbit.core.query.AbstractQueryHandler
org.apache.jackrabbit.core.query.lucene.SearchIndex
public class SearchIndex
Implements a QueryHandler
using
Lucene.
Nested Class Summary | |
---|---|
protected static class |
SearchIndex.CombinedIndexReader
Combines multiple CachingMultiReader into a MultiReader
with HierarchyResolver support. |
Field Summary | |
---|---|
static int |
DEFAULT_EXTRACTOR_BACK_LOG
The default value for property extractorBackLog . |
static int |
DEFAULT_EXTRACTOR_POOL_SIZE
The default value for property extractorPoolSize . |
static long |
DEFAULT_EXTRACTOR_TIMEOUT
The default timeout in milliseconds which is granted to the text extraction process until fulltext indexing is deferred to a background thread. |
static int |
DEFAULT_MAX_FIELD_LENGTH
the default value for property maxFieldLength . |
static int |
DEFAULT_MAX_MERGE_DOCS
The default value for property maxMergeDocs . |
static int |
DEFAULT_MERGE_FACTOR
the default value for property mergeFactor . |
static int |
DEFAULT_MIN_MERGE_DOCS
The default value for property minMergeDocs . |
Constructor Summary | |
---|---|
SearchIndex()
Default constructor. |
Method Summary | |
---|---|
void |
addNode(NodeState node)
Adds the node to the search index. |
void |
close()
Closes this QueryHandler and frees resources attached
to this handler. |
protected org.apache.lucene.document.Document |
createDocument(NodeState node,
NamespaceMappings nsMappings)
Creates a lucene Document for a node state using the
namespace mappings nsMappings . |
ExcerptProvider |
createExcerptProvider(org.apache.lucene.search.Query query)
Creates an excerpt provider for the given query . |
ExecutableQuery |
createExecutableQuery(SessionImpl session,
ItemManager itemMgr,
String statement,
String language)
Creates a new query by specifying the query statement itself and the language in which the query is stated. |
protected org.apache.lucene.search.SortField[] |
createSortFields(QName[] orderProps,
boolean[] orderSpecs)
Creates the SortFields for the order properties. |
protected TextExtractor |
createTextExtractor()
Factory method to create the TextExtractor instance. |
void |
deleteNode(NodeId id)
Removes the node with uuid from the search index. |
protected void |
doInit()
Initializes this QueryHandler . |
QueryHits |
executeQuery(QueryImpl queryImpl,
org.apache.lucene.search.Query query,
QName[] orderProps,
boolean[] orderSpecs)
Executes the query on the search index. |
String |
getAnalyzer()
Returns the class name of the analyzer that is currently in use. |
boolean |
getAutoRepair()
|
int |
getBufferSize()
Returns the current value for the buffer size. |
int |
getCacheSize()
|
String |
getExcerptProviderClass()
|
int |
getExtractorBackLogSize()
|
int |
getExtractorPoolSize()
|
long |
getExtractorTimeout()
|
boolean |
getForceConsistencyCheck()
|
protected MultiIndex |
getIndex()
Returns the actual index. |
org.apache.lucene.index.IndexReader |
getIndexReader()
Returns an index reader for this search index. |
int |
getMaxFieldLength()
|
int |
getMaxMergeDocs()
Returns the current value for maxMergeDocs. |
int |
getMergeFactor()
Returns the current value for the merge factor. |
int |
getMinMergeDocs()
Returns the current value for minMergeDocs. |
NamespaceMappings |
getNamespaceMappings()
Returns the namespace mappings for the internal representation. |
String |
getPath()
Returns the location of the search index. |
boolean |
getRespectDocumentOrder()
|
int |
getResultFetchSize()
|
boolean |
getSupportHighlighting()
|
org.apache.lucene.analysis.Analyzer |
getTextAnalyzer()
Returns the analyzer in use for indexing. |
TextExtractor |
getTextExtractor()
Returns the text extractor in use for indexing. |
String |
getTextFilterClasses()
Returns the fully qualified class names of the text filter instances currently in use. |
boolean |
getUseCompoundFile()
Returns the current value for useCompoundFile. |
int |
getVolatileIdleTime()
Returns the current value for volatileIdleTime. |
void |
setAnalyzer(String analyzerClassName)
Sets the analyzer in use for indexing. |
void |
setAutoRepair(boolean b)
|
void |
setBufferSize(int size)
|
void |
setCacheSize(int size)
|
void |
setExcerptProviderClass(String className)
Sets the class name for the ExcerptProvider that should be used
for the rep:excerpt pseudo property in a query. |
void |
setExtractorBackLogSize(int backLog)
The number of extractor jobs that are queued until a new job is executed with the current thread instead of using the thread pool. |
void |
setExtractorPoolSize(int numThreads)
The number of background threads for the extractor pool. |
void |
setExtractorTimeout(long timeout)
The timeout in milliseconds which is granted to the text extraction process until fulltext indexing is deferred to a background thread. |
void |
setForceConsistencyCheck(boolean b)
|
void |
setMaxFieldLength(int length)
|
void |
setMaxMergeDocs(int maxMergeDocs)
The lucene index writer property: maxMergeDocs |
void |
setMergeFactor(int mergeFactor)
The lucene index writer property: mergeFactor |
void |
setMinMergeDocs(int minMergeDocs)
The lucene index writer property: minMergeDocs |
void |
setPath(String path)
Sets the location of the search index. |
void |
setRespectDocumentOrder(boolean docOrder)
|
void |
setResultFetchSize(int size)
Tells the query handler how many result should be fetched initially when a query is executed. |
void |
setSupportHighlighting(boolean b)
If set to true additional information is stored in the index
to support highlighting using the rep:excerpt pseudo property. |
void |
setTextFilterClasses(String filterClasses)
Sets the list of text extractors (and text filters) to use for extracting text content from binary properties. |
void |
setUseCompoundFile(boolean b)
The lucene index writer property: useCompoundFile |
void |
setVolatileIdleTime(int volatileIdleTime)
Sets the property: volatileIdleTime |
void |
updateNodes(NodeIdIterator remove,
NodeStateIterator add)
This implementation forwards the call to MultiIndex.update(java.util.Iterator, java.util.Iterator) and
transforms the two iterators to the required types. |
Methods inherited from class org.apache.jackrabbit.core.query.AbstractQueryHandler |
---|
getContext, init |
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_MIN_MERGE_DOCS
minMergeDocs
.
public static final int DEFAULT_MAX_MERGE_DOCS
maxMergeDocs
.
public static final int DEFAULT_MERGE_FACTOR
mergeFactor
.
public static final int DEFAULT_MAX_FIELD_LENGTH
maxFieldLength
.
public static final int DEFAULT_EXTRACTOR_POOL_SIZE
extractorPoolSize
.
public static final int DEFAULT_EXTRACTOR_BACK_LOG
extractorBackLog
.
public static final long DEFAULT_EXTRACTOR_TIMEOUT
Constructor Detail |
---|
public SearchIndex()
Method Detail |
---|
protected void doInit() throws IOException
QueryHandler
. This implementation requires
that a path parameter is set in the configuration. If this condition
is not met, a IOException
is thrown.
doInit
in class AbstractQueryHandler
IOException
- if an error occurs while initializing this handler.public void addNode(NodeState node) throws RepositoryException, IOException
node
to the search index.
node
- the node to add.
RepositoryException
- if an error occurs while indexing the node.
IOException
- if an error occurs while adding the node to the index.public void deleteNode(NodeId id) throws IOException
uuid
from the search index.
id
- the id of the node to remove from the index.
IOException
- if an error occurs while removing the node from
the index.public void updateNodes(NodeIdIterator remove, NodeStateIterator add) throws RepositoryException, IOException
MultiIndex.update(java.util.Iterator, java.util.Iterator)
and
transforms the two iterators to the required types.
updateNodes
in interface QueryHandler
updateNodes
in class AbstractQueryHandler
remove
- uuids of nodes to remove.add
- NodeStates to add. Calls to next()
on this
iterator may return null
, to indicate that a
node could not be indexed successfully.
RepositoryException
- if an error occurs while indexing a node.
IOException
- if an error occurs while updating the index.public ExecutableQuery createExecutableQuery(SessionImpl session, ItemManager itemMgr, String statement, String language) throws InvalidQueryException
language
must specify a query language
string from among those returned by QueryManager.getSupportedQueryLanguages(); if it is not
then an InvalidQueryException
is thrown.
session
- the session of the current user creating the query object.itemMgr
- the item manager of the current user.statement
- the query statement.language
- the syntax of the query statement.
Query
object.
InvalidQueryException
- if statement is invalid or language is unsupported.public void close()
QueryHandler
and frees resources attached
to this handler.
public QueryHits executeQuery(QueryImpl queryImpl, org.apache.lucene.search.Query query, QName[] orderProps, boolean[] orderSpecs) throws IOException
queryImpl
- the query impl.query
- the lucene query.orderProps
- name of the properties for sort order.orderSpecs
- the order specs for the sort order properties.
true
indicates ascending order, false
indicates
descending.
IOException
- if an error occurs while searching the index.public ExcerptProvider createExcerptProvider(org.apache.lucene.search.Query query) throws IOException
query
.
query
- the query.
query
.
IOException
- if the provider cannot be created.public org.apache.lucene.analysis.Analyzer getTextAnalyzer()
public TextExtractor getTextExtractor()
public NamespaceMappings getNamespaceMappings()
public org.apache.lucene.index.IndexReader getIndexReader() throws IOException
IOException
- the index reader cannot be obtained.protected org.apache.lucene.search.SortField[] createSortFields(QName[] orderProps, boolean[] orderSpecs)
orderProps
- the order properties.orderSpecs
- the order specs for the properties.
protected org.apache.lucene.document.Document createDocument(NodeState node, NamespaceMappings nsMappings) throws RepositoryException
Document
for a node state using the
namespace mappings nsMappings
.
node
- the node state to index.nsMappings
- the namespace mappings of the search index.
Document
that contains all properties of
node
.
RepositoryException
- if an error occurs while indexing the
node
.protected MultiIndex getIndex()
protected TextExtractor createTextExtractor()
TextExtractor
instance.
TextExtractor
instance this index should use.public void setAnalyzer(String analyzerClassName)
If the above conditions are met, then a new instance of the class is set as the analyzer. Otherwise a warning is logged and the current analyzer is not changed.
This property setter method is normally invoked by the Jackrabbit configuration mechanism if the "analyzer" parameter is set in the search configuration.
analyzerClassName
- the analyzer class namepublic String getAnalyzer()
public void setPath(String path)
path
- the location of the search index.public String getPath()
null
if
not set.
public void setUseCompoundFile(boolean b)
public boolean getUseCompoundFile()
public void setMinMergeDocs(int minMergeDocs)
public int getMinMergeDocs()
public void setVolatileIdleTime(int volatileIdleTime)
volatileIdleTime
- idle time in secondspublic int getVolatileIdleTime()
public void setMaxMergeDocs(int maxMergeDocs)
public int getMaxMergeDocs()
public void setMergeFactor(int mergeFactor)
public int getMergeFactor()
public void setBufferSize(int size)
VolatileIndex#setBufferSize(int)
public int getBufferSize()
public void setRespectDocumentOrder(boolean docOrder)
public boolean getRespectDocumentOrder()
public void setForceConsistencyCheck(boolean b)
public boolean getForceConsistencyCheck()
public void setAutoRepair(boolean b)
public boolean getAutoRepair()
public void setCacheSize(int size)
public int getCacheSize()
public void setMaxFieldLength(int length)
public int getMaxFieldLength()
public void setTextFilterClasses(String filterClasses)
TextExtractor
(and TextFilter
) classes
to be used. The configured classes must all have a public default
constructor.
filterClasses
- comma separated list of class namespublic String getTextFilterClasses()
public void setResultFetchSize(int size)
size
- the number of results to fetch initially.public int getResultFetchSize()
public void setExtractorPoolSize(int numThreads)
numThreads
- the number of threads.public int getExtractorPoolSize()
public void setExtractorBackLogSize(int backLog)
backLog
- size of the extractor job queue.public int getExtractorBackLogSize()
public void setExtractorTimeout(long timeout)
timeout
- the timeout in milliseconds.public long getExtractorTimeout()
public void setSupportHighlighting(boolean b)
true
additional information is stored in the index
to support highlighting using the rep:excerpt pseudo property.
b
- true
to enable highlighting support.public boolean getSupportHighlighting()
true
if highlighting support is enabled.public void setExcerptProviderClass(String className)
ExcerptProvider
that should be used
for the rep:excerpt pseudo property in a query.
className
- the name of a class that implements ExcerptProvider
.public String getExcerptProviderClass()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |