org.alfresco.repo.search.impl.lucene
Class ADMLuceneSearcherImpl

java.lang.Object
  extended by org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
      extended by org.alfresco.repo.search.impl.lucene.ADMLuceneSearcherImpl
All Implemented Interfaces:
LuceneSearcher, SearchService

public class ADMLuceneSearcherImpl
extends AbstractLuceneBase
implements LuceneSearcher

The Lucene implementation of Searcher At the moment we support only lucene based queries. TODO: Support for other query languages


Field Summary
 
Fields inherited from class org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
deltaId, store
 
Fields inherited from interface org.alfresco.service.cmr.search.SearchService
LANGUAGE_CMIS_ALFRESCO, LANGUAGE_CMIS_STRICT, LANGUAGE_FTS_ALFRESCO, LANGUAGE_JCR_XPATH, LANGUAGE_LUCENE, LANGUAGE_XPATH
 
Constructor Summary
ADMLuceneSearcherImpl()
           
 
Method Summary
 boolean contains(NodeRef nodeRef, QName propertyQName, java.lang.String googleLikePattern)
          Search for string pattern in both the node text (if present) and node properties
 boolean contains(NodeRef nodeRef, QName propertyQName, java.lang.String googleLikePattern, SearchParameters.Operator defaultOperator)
          Search for string pattern in both the node text (if present) and node properties
static boolean fieldHasTerm(org.apache.lucene.index.IndexReader indexReader, java.lang.String field)
           
 ClosingIndexSearcher getClosingIndexSearcher()
          Get a lucene searcher
 NamespacePrefixResolver getNamespacePrefixResolver()
           
static ADMLuceneSearcherImpl getNodeSearcher()
          Get a select-node-based searcher
 NodeService getNodeService()
           
 QueryRegisterComponent getQueryRegister()
           
static ADMLuceneSearcherImpl getSearcher(StoreRef storeRef, LuceneConfig config)
          Get an intialised searcher for the store.
static ADMLuceneSearcherImpl getSearcher(StoreRef storeRef, LuceneIndexer indexer, LuceneConfig config)
          Get an initialised searcher for the store and transaction Normally we do not search against a a store and delta.
 TenantService getTenantService()
           
 java.util.List getTopTerms(java.lang.String field, int count)
          Get top terms
 boolean indexExists()
          Check if the index exists
 boolean like(NodeRef nodeRef, QName propertyQName, java.lang.String sqlLikePattern, boolean includeFTS)
          Search for string pattern in both the node text (if present) and node properties
 ResultSet query(SearchParameters searchParameters)
          Search using the given SearchParameters
 ResultSet query(StoreRef store, QName queryId, QueryParameter[] queryParameters)
          Execute a canned query
 ResultSet query(StoreRef store, java.lang.String language, java.lang.String query)
          Search against a store.
 ResultSet query(StoreRef store, java.lang.String language, java.lang.String queryString, QueryParameterDefinition[] queryParameterDefinitions)
          Search against a store.
 java.util.List selectNodes(NodeRef contextNodeRef, java.lang.String xpath, QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver, boolean followAllParentLinks)
          Select nodes using an xpath expression.
 java.util.List selectNodes(NodeRef contextNodeRef, java.lang.String xpath, QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver, boolean followAllParentLinks, java.lang.String language)
          Select nodes using an xpath expression.
 java.util.List selectProperties(NodeRef contextNodeRef, java.lang.String xpath, QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver, boolean followAllParentLinks)
          Select properties using an xpath expression
 java.util.List selectProperties(NodeRef contextNodeRef, java.lang.String xpath, QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver, boolean followAllParentLinks, java.lang.String language)
          Select properties using an xpath expression
 void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver)
          Set the name space service
 void setNodeService(NodeService nodeService)
          Ste the node service
 void setQueryLanguages(java.util.Map queryLanguages)
           
 void setQueryRegister(QueryRegisterComponent queryRegister)
          Set the query register
 void setTenantService(TenantService tenantService)
           
 
Methods inherited from class org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
closeDeltaReader, closeDeltaWriter, deleteIndex, doWithWriteLock, getDeltaId, getDeltaReader, getDeltaWriter, getDictionaryService, getLuceneConfig, getReader, getSearcher, getSearcher, getStatus, initialise, saveDelta, setDictionaryService, setInfo, setLuceneConfig, setStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ADMLuceneSearcherImpl

public ADMLuceneSearcherImpl()
Method Detail

getSearcher

public static ADMLuceneSearcherImpl getSearcher(StoreRef storeRef,
                                                LuceneIndexer indexer,
                                                LuceneConfig config)
Get an initialised searcher for the store and transaction Normally we do not search against a a store and delta. Currently only gets the searcher against the main index.

Parameters:
storeRef -
indexer -
config -
Returns:
- the searcher implementation

getSearcher

public static ADMLuceneSearcherImpl getSearcher(StoreRef storeRef,
                                                LuceneConfig config)
Get an intialised searcher for the store. No transactional ammendsmends are searched.

Parameters:
storeRef -
config -
Returns:
the searcher

getNodeSearcher

public static ADMLuceneSearcherImpl getNodeSearcher()
Get a select-node-based searcher

Returns:

setNamespacePrefixResolver

public void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver)
Description copied from interface: LuceneSearcher
Set the name space service

Specified by:
setNamespacePrefixResolver in interface LuceneSearcher

getNamespacePrefixResolver

public NamespacePrefixResolver getNamespacePrefixResolver()

getNodeService

public NodeService getNodeService()

getTenantService

public TenantService getTenantService()

getQueryRegister

public QueryRegisterComponent getQueryRegister()

indexExists

public boolean indexExists()
Description copied from interface: LuceneSearcher
Check if the index exists

Specified by:
indexExists in interface LuceneSearcher
Returns:
- true if it exists

setNodeService

public void setNodeService(NodeService nodeService)
Description copied from interface: LuceneSearcher
Ste the node service

Specified by:
setNodeService in interface LuceneSearcher

setTenantService

public void setTenantService(TenantService tenantService)

setQueryRegister

public void setQueryRegister(QueryRegisterComponent queryRegister)
Set the query register

Parameters:
queryRegister -

setQueryLanguages

public void setQueryLanguages(java.util.Map queryLanguages)

query

public ResultSet query(StoreRef store,
                       java.lang.String language,
                       java.lang.String queryString,
                       QueryParameterDefinition[] queryParameterDefinitions)
                throws SearcherException
Description copied from interface: SearchService
Search against a store.

Specified by:
query in interface SearchService
Parameters:
store - - the store against which to search
language - - the query language
queryString - - the query string - which may include parameters
Returns:
Returns the query results
Throws:
SearcherException

query

public ResultSet query(SearchParameters searchParameters)
Description copied from interface: SearchService
Search using the given SearchParameters

Specified by:
query in interface SearchService

fieldHasTerm

public static boolean fieldHasTerm(org.apache.lucene.index.IndexReader indexReader,
                                   java.lang.String field)

query

public ResultSet query(StoreRef store,
                       java.lang.String language,
                       java.lang.String query)
Description copied from interface: SearchService
Search against a store. Pulls back all attributes on each node. Does not allow parameterisation.

Specified by:
query in interface SearchService
Parameters:
store - - the store against which to search
language - - the query language
query - - the query string - which may include parameters
Returns:
Returns the query results

query

public ResultSet query(StoreRef store,
                       QName queryId,
                       QueryParameter[] queryParameters)
Description copied from interface: SearchService
Execute a canned query

Specified by:
query in interface SearchService
Parameters:
store - - the store against which to search
queryId - - the query identifier
queryParameters - - parameterisation for the canned query
Returns:
Returns the query results

selectNodes

public java.util.List selectNodes(NodeRef contextNodeRef,
                                  java.lang.String xpath,
                                  QueryParameterDefinition[] parameters,
                                  NamespacePrefixResolver namespacePrefixResolver,
                                  boolean followAllParentLinks,
                                  java.lang.String language)
                           throws InvalidNodeRefException,
                                  XPathException
Description copied from interface: SearchService
Select nodes using an xpath expression.

Specified by:
selectNodes in interface SearchService
Parameters:
contextNodeRef - - the context node for relative expressions etc
xpath - - the xpath string to evaluate
parameters - - parameters to bind in to the xpath expression
namespacePrefixResolver - - prefix to namespace mappings
followAllParentLinks - - if false ".." follows only the primary parent links, if true it follows all
Returns:
a list of all the child assoc relationships to the selected nodes
Throws:
InvalidNodeRefException
XPathException
See Also:
NodeSearcher

selectProperties

public java.util.List selectProperties(NodeRef contextNodeRef,
                                       java.lang.String xpath,
                                       QueryParameterDefinition[] parameters,
                                       NamespacePrefixResolver namespacePrefixResolver,
                                       boolean followAllParentLinks,
                                       java.lang.String language)
                                throws InvalidNodeRefException,
                                       XPathException
Description copied from interface: SearchService
Select properties using an xpath expression

Specified by:
selectProperties in interface SearchService
Parameters:
contextNodeRef - - the context node for relative expressions etc
xpath - - the xpath string to evaluate
parameters - - parameters to bind in to the xpath expression
namespacePrefixResolver - - prefix to namespace mappings
followAllParentLinks - - if false ".." follows only the primary parent links, if true it follows all
Returns:
a list of property values
Throws:
InvalidNodeRefException
XPathException
See Also:
NodeSearcher

contains

public boolean contains(NodeRef nodeRef,
                        QName propertyQName,
                        java.lang.String googleLikePattern)
Description copied from interface: SearchService
Search for string pattern in both the node text (if present) and node properties

Specified by:
contains in interface SearchService
Parameters:
nodeRef - the node to get
propertyQName - the name of the property
googleLikePattern - a Google-like pattern to search for in the property value
Returns:
Returns true if the pattern is present, otherwise false.

contains

public boolean contains(NodeRef nodeRef,
                        QName propertyQName,
                        java.lang.String googleLikePattern,
                        SearchParameters.Operator defaultOperator)
Description copied from interface: SearchService
Search for string pattern in both the node text (if present) and node properties

Specified by:
contains in interface SearchService
Parameters:
nodeRef - the node to get
propertyQName - the name of the property
googleLikePattern - a Google-like pattern to search for in the property value
Returns:
Returns true if the pattern is present, otherwise false.

like

public boolean like(NodeRef nodeRef,
                    QName propertyQName,
                    java.lang.String sqlLikePattern,
                    boolean includeFTS)
Description copied from interface: SearchService
Search for string pattern in both the node text (if present) and node properties

Specified by:
like in interface SearchService
Parameters:
nodeRef - the node to get
propertyQName - the name of the property (mandatory)
sqlLikePattern - a SQL-like pattern to search for
includeFTS - - include full text search matches in the like test
Returns:
Returns true if the pattern is present, otherwise false.

selectNodes

public java.util.List selectNodes(NodeRef contextNodeRef,
                                  java.lang.String xpath,
                                  QueryParameterDefinition[] parameters,
                                  NamespacePrefixResolver namespacePrefixResolver,
                                  boolean followAllParentLinks)
                           throws InvalidNodeRefException,
                                  XPathException
Description copied from interface: SearchService
Select nodes using an xpath expression.

Specified by:
selectNodes in interface SearchService
Parameters:
contextNodeRef - - the context node for relative expressions etc
xpath - - the xpath string to evaluate
parameters - - parameters to bind in to the xpath expression
namespacePrefixResolver - - prefix to namespace mappings
followAllParentLinks - - if false ".." follows only the primary parent links, if true it follows all
Returns:
a list of all the child assoc relationships to the selected nodes
Throws:
InvalidNodeRefException
XPathException

selectProperties

public java.util.List selectProperties(NodeRef contextNodeRef,
                                       java.lang.String xpath,
                                       QueryParameterDefinition[] parameters,
                                       NamespacePrefixResolver namespacePrefixResolver,
                                       boolean followAllParentLinks)
                                throws InvalidNodeRefException,
                                       XPathException
Description copied from interface: SearchService
Select properties using an xpath expression

Specified by:
selectProperties in interface SearchService
Parameters:
contextNodeRef - - the context node for relative expressions etc
xpath - - the xpath string to evaluate
parameters - - parameters to bind in to the xpath expression
namespacePrefixResolver - - prefix to namespace mappings
followAllParentLinks - - if false ".." follows only the primary parent links, if true it follows all
Returns:
a list of property values
Throws:
InvalidNodeRefException
XPathException

getTopTerms

public java.util.List getTopTerms(java.lang.String field,
                                  int count)
Description copied from interface: LuceneSearcher
Get top terms

Specified by:
getTopTerms in interface LuceneSearcher
Returns:

getClosingIndexSearcher

public ClosingIndexSearcher getClosingIndexSearcher()
Description copied from interface: LuceneSearcher
Get a lucene searcher

Specified by:
getClosingIndexSearcher in interface LuceneSearcher
Returns:


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.