Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.platform.search.ejb
Class SearchServiceBean

java.lang.Object
  extended by org.nuxeo.ecm.platform.search.ejb.SearchServiceBean
All Implemented Interfaces:
java.io.Serializable, SearchService

public class SearchServiceBean
extends java.lang.Object
implements SearchService

Search service session bean.

This session bean expects the Nuxeo Runtime core search service available locally (i.e : same JVM).

Author:
Julien Anguenot
See Also:
Serialized Form

Constructor Summary
SearchServiceBean()
           
 
Method Summary
 void clear()
          Completely erases the indexes.
 void closeSession(java.lang.String sid)
          Closes a search service session given its identifier.
 void deleteAggregatedResources(java.lang.String key)
          Deletes an index given an aggregated resources key.
 void deleteAtomicResource(java.lang.String key)
          Deletes an atomic resource given its key.
 int getActiveIndexingTasks()
          Returns the number of running indexing tasks.
 java.lang.String[] getAvailableBackendNames()
          Returns the list of all backend names.
 BlobExtractor getBlobExtractorByName(java.lang.String name)
          Returns a blob extractor given its name.
 FulltextFieldDescriptor getFullTextDescriptorByName(java.lang.String prefixedName)
          Returns the full text descriptor given its name.
 IndexableDocType getIndexableDocTypeFor(java.lang.String docType)
          Return the indexing information for a given nuxeo core doc type.
 IndexableResourceConf getIndexableResourceConfByName(java.lang.String name, boolean full)
          Returns an indexable resource configuration given its name.
 IndexableResourceConf getIndexableResourceConfByPrefix(java.lang.String prefix, boolean full)
          Returns an indexable resource configuration given its prefix.
 java.util.Map<java.lang.String,IndexableResourceConf> getIndexableResourceConfs()
          Returns all the indexable resource configurations registred.
 int getIndexingDocBatchSize()
          Returns the document batch size.
 IndexingEventConf getIndexingEventConfByName(java.lang.String name)
          Returns an indexing event configuration given its name.
 long getIndexingWaitingQueueSize()
          Returns the number of indexing tasks waiting for a slot in the ThreadPool executor.
 int getNumberOfIndexingThreads()
          Returns the amount of threads the search service will be able to instanciate within its thread pool.
 ResourceTypeDescriptor getResourceTypeDescriptorByName(java.lang.String name)
          Returns a resource type descriptor instance.
 SearchPrincipal getSearchPrincipal(java.security.Principal principal)
          Computes a search principal out from a principal instance.
 java.util.List<java.lang.String> getSupportedAnalyzersFor(java.lang.String backendName)
          Returns the supported analyers for a given backend.
 java.util.List<java.lang.String> getSupportedFieldTypes(java.lang.String backendName)
          Returns the supported fieldd types for a given backend.
 long getTotalCompletedIndexingTasks()
          Returns the total number of completed indexing tasks.
 void index(IndexableResources sources, boolean fulltext)
          Adds / updates index(es) given an IndexableResources instance.
 void index(ResolvedResources sources)
          Adds / updates index(es) given (ResolvedResources This method is useful for performing the resource resolution outside the search service.
 void invalidateComputedIndexableResourceConfs()
          Invalidates the computed indexable resource confs.
 boolean isEnabled()
          Is the search service enabled?
 boolean isReindexingAll()
          Is the search service reindexing the while indexes?
 SearchServiceSession openSession()
          Opens a new session against the search service.
 void reindexAll(java.lang.String repoName, java.lang.String path, boolean fulltext)
          Deprecated. 
 void saveAllSessions()
          Saves all the pending sessions.
 ResultSet searchQuery(ComposedNXQuery nxqlQuery, int offset, int range)
          Searches results given an NXQL query.
 ResultSet searchQuery(NativeQuery nativeQuery, int offset, int range)
          Searches results given a backend native query wrapper.
 ResultSet searchQuery(NativeQueryString queryString, java.lang.String backendName, int offset, int range)
          Searches results given a backend native query string.
 void setIndexingDocBatchSize(int docBatchSize)
          Sets the document batch size.
 void setNumberOfIndexingThreads(int numberOfIndexingThreads)
          Sets the amount of threads the search service will be able to instanciate within its thread pool.
 void setReindexingAll(boolean flag)
          Reindex all setter.
 void setStatus(boolean active)
          Sets the status of the search service.
 void unindex(DocumentModel dm)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SearchServiceBean

public SearchServiceBean()
Method Detail

deleteAggregatedResources

public void deleteAggregatedResources(java.lang.String key)
                               throws IndexingException
Description copied from interface: SearchService
Deletes an index given an aggregated resources key.

This will remove all resources indexed with key as key used to identified the set ot resources. See ResolvedResources.getId()

Specified by:
deleteAggregatedResources in interface SearchService
Parameters:
key - aggregated resources key.
Throws:
IndexingException

deleteAtomicResource

public void deleteAtomicResource(java.lang.String key)
                          throws IndexingException
Description copied from interface: SearchService
Deletes an atomic resource given its key.

This will remove the resource identified by this resource key only.

Specified by:
deleteAtomicResource in interface SearchService
Parameters:
key - atomic resource key
Throws:
IndexingException

index

public void index(IndexableResources sources,
                  boolean fulltext)
           throws IndexingException
Description copied from interface: SearchService
Adds / updates index(es) given an IndexableResources instance.

The actual resolution in this case will be done search service side.

Specified by:
index in interface SearchService
Parameters:
sources - an IndexableResources instance
fulltext - do compute fulltext at resolution time
Throws:
IndexingException - wrap low level backend exception

unindex

public void unindex(DocumentModel dm)
             throws IndexingException
Specified by:
unindex in interface SearchService
Throws:
IndexingException

searchQuery

public ResultSet searchQuery(NativeQuery nativeQuery,
                             int offset,
                             int range)
                      throws SearchException,
                             QueryException
Description copied from interface: SearchService
Searches results given a backend native query wrapper.

Specified by:
searchQuery in interface SearchService
Parameters:
nativeQuery - the backend native query wrapper.
offset - pagination start
range - number of results
Returns:
a result set instance
Throws:
SearchException - wrap low level backend exception
QueryException - if the query is invalid or unsupported

searchQuery

public ResultSet searchQuery(ComposedNXQuery nxqlQuery,
                             int offset,
                             int range)
                      throws SearchException,
                             QueryException
Description copied from interface: SearchService
Searches results given an NXQL query.

Specified by:
searchQuery in interface SearchService
Parameters:
nxqlQuery - a NXQL query instance
offset - pagination start
range - number of results
Returns:
a ResultSet instance
Throws:
SearchException - wrap low level backend exception
QueryException - if the query is invalid or unsupported

searchQuery

public ResultSet searchQuery(NativeQueryString queryString,
                             java.lang.String backendName,
                             int offset,
                             int range)
                      throws SearchException,
                             QueryException
Description copied from interface: SearchService
Searches results given a backend native query string.

Specified by:
searchQuery in interface SearchService
Parameters:
queryString - the backend native query string wrapper.
backendName - the backened name to apply the query on. If backened name is null then use the default indexing backends
offset - pagination start
range - number of results
Returns:
a result set instance
Throws:
SearchException - wrap low level backend exception
QueryException - wrong query, rewrapped from backend

getSupportedAnalyzersFor

public java.util.List<java.lang.String> getSupportedAnalyzersFor(java.lang.String backendName)
Description copied from interface: SearchService
Returns the supported analyers for a given backend.

Specified by:
getSupportedAnalyzersFor in interface SearchService
Parameters:
backendName - the backend name.
Returns:
a list of identifiers.

getSupportedFieldTypes

public java.util.List<java.lang.String> getSupportedFieldTypes(java.lang.String backendName)
Description copied from interface: SearchService
Returns the supported fieldd types for a given backend.

Specified by:
getSupportedFieldTypes in interface SearchService
Parameters:
backendName - the backend name.
Returns:
a list of identifiers.

getIndexableResourceConfByName

public IndexableResourceConf getIndexableResourceConfByName(java.lang.String name,
                                                            boolean full)
Description copied from interface: SearchService
Returns an indexable resource configuration given its name.

Specified by:
getIndexableResourceConfByName in interface SearchService
Parameters:
name - the name of the indexable resource configuration.
full - compute automatic configuration to get the full resource configuration
Returns:
an indexable resource configuration instance given its name.

getIndexableDocTypeFor

public IndexableDocType getIndexableDocTypeFor(java.lang.String docType)
Description copied from interface: SearchService
Return the indexing information for a given nuxeo core doc type.

Specified by:
getIndexableDocTypeFor in interface SearchService
Parameters:
docType - doc type indentifier.
Returns:
an indexable doc type instance.

getIndexableResourceConfs

public java.util.Map<java.lang.String,IndexableResourceConf> getIndexableResourceConfs()
Description copied from interface: SearchService
Returns all the indexable resource configurations registred.

Specified by:
getIndexableResourceConfs in interface SearchService
Returns:
the a map from indexable resource configuration name to indexable resource configuration instance.

getAvailableBackendNames

public java.lang.String[] getAvailableBackendNames()
Description copied from interface: SearchService
Returns the list of all backend names.

Specified by:
getAvailableBackendNames in interface SearchService
Returns:
the list of all backend names.

getSearchPrincipal

public SearchPrincipal getSearchPrincipal(java.security.Principal principal)
Description copied from interface: SearchService
Computes a search principal out from a principal instance.

NuxeoPrincipal instance is expected for groups support.

Specified by:
getSearchPrincipal in interface SearchService
Parameters:
principal - a java principal instance
Returns:
a search principal instance

getIndexableResourceConfByPrefix

public IndexableResourceConf getIndexableResourceConfByPrefix(java.lang.String prefix,
                                                              boolean full)
Description copied from interface: SearchService
Returns an indexable resource configuration given its prefix.

Specified by:
getIndexableResourceConfByPrefix in interface SearchService
Parameters:
prefix - the prefix of the indexable resource configuration.
full - compute automatic configuration to get the full resource configuration
Returns:
an indexable resource configuration instance given its name.

isEnabled

public boolean isEnabled()
Description copied from interface: SearchService
Is the search service enabled?

It is possible to disable the search service using extension point parameter.

Specified by:
isEnabled in interface SearchService
Returns:
true if active / false if inactive.

setStatus

public void setStatus(boolean active)
Description copied from interface: SearchService
Sets the status of the search service.

Specified by:
setStatus in interface SearchService
Parameters:
active - if active is true, then the service will be activated

getFullTextDescriptorByName

public FulltextFieldDescriptor getFullTextDescriptorByName(java.lang.String prefixedName)
Description copied from interface: SearchService
Returns the full text descriptor given its name.

Specified by:
getFullTextDescriptorByName in interface SearchService
Parameters:
prefixedName - the prefixed name with what it's been registered using extension point.
Returns:
a full text field descriptor.

getIndexingEventConfByName

public IndexingEventConf getIndexingEventConfByName(java.lang.String name)
Description copied from interface: SearchService
Returns an indexing event configuration given its name.

Specified by:
getIndexingEventConfByName in interface SearchService
Parameters:
name - the name under which it's been registered using extension point.
Returns:
the configuration object.

invalidateComputedIndexableResourceConfs

public void invalidateComputedIndexableResourceConfs()
Description copied from interface: SearchService
Invalidates the computed indexable resource confs.

Will be useful if Nuxeo Runtime supports hot deployment in the future.

Specified by:
invalidateComputedIndexableResourceConfs in interface SearchService

clear

public void clear()
           throws IndexingException
Description copied from interface: SearchService
Completely erases the indexes.

Specified by:
clear in interface SearchService
Throws:
IndexingException

getBlobExtractorByName

public BlobExtractor getBlobExtractorByName(java.lang.String name)
Description copied from interface: SearchService
Returns a blob extractor given its name.

Specified by:
getBlobExtractorByName in interface SearchService
Parameters:
name - the name against which the full text extractor has been registered using extension point.
Returns:

getResourceTypeDescriptorByName

public ResourceTypeDescriptor getResourceTypeDescriptorByName(java.lang.String name)
Description copied from interface: SearchService
Returns a resource type descriptor instance.

Specified by:
getResourceTypeDescriptorByName in interface SearchService
Parameters:
name - the resource type name which has been used with extension point.
Returns:
a resource type descriptor instance

index

public void index(ResolvedResources sources)
           throws IndexingException
Description copied from interface: SearchService
Adds / updates index(es) given (ResolvedResources

This method is useful for performing the resource resolution outside the search service.

Specified by:
index in interface SearchService
Parameters:
sources - resolved resources
Throws:
IndexingException - wrap low level backend exception

getIndexingWaitingQueueSize

public long getIndexingWaitingQueueSize()
Description copied from interface: SearchService
Returns the number of indexing tasks waiting for a slot in the ThreadPool executor.

Specified by:
getIndexingWaitingQueueSize in interface SearchService
Returns:

getNumberOfIndexingThreads

public int getNumberOfIndexingThreads()
Description copied from interface: SearchService
Returns the amount of threads the search service will be able to instanciate within its thread pool.

Specified by:
getNumberOfIndexingThreads in interface SearchService
Returns:
the number of threads max

closeSession

public void closeSession(java.lang.String sid)
Description copied from interface: SearchService
Closes a search service session given its identifier.

Specified by:
closeSession in interface SearchService
Parameters:
sid - the search service identifier

openSession

public SearchServiceSession openSession()
Description copied from interface: SearchService
Opens a new session against the search service.

Warning: for now on the client is responsible for closing the session.

Specified by:
openSession in interface SearchService
Returns:
a search service session.

getIndexingDocBatchSize

public int getIndexingDocBatchSize()
Description copied from interface: SearchService
Returns the document batch size.

In case of batch indexing we can choose to save the indexing session for a given amount of document. Default is one meaning the session is saved after every insertion. You might want to increase this while performing bulk document imports.

Specified by:
getIndexingDocBatchSize in interface SearchService
Returns:
number of of document per indexing session before save()

setIndexingDocBatchSize

public void setIndexingDocBatchSize(int docBatchSize)
Description copied from interface: SearchService
Sets the document batch size.

In case of batch indexing we can choose to save the indexing session for a given amount of document. Default is one meaning the session is saved after every insertion. You might want to increase this while performing bulk document imports.

Specified by:
setIndexingDocBatchSize in interface SearchService
Parameters:
docBatchSize - number of of document per indexing session before save()

setNumberOfIndexingThreads

public void setNumberOfIndexingThreads(int numberOfIndexingThreads)
Description copied from interface: SearchService
Sets the amount of threads the search service will be able to instanciate within its thread pool.

Specified by:
setNumberOfIndexingThreads in interface SearchService
Parameters:
numberOfIndexingThreads - : the number of threads max

saveAllSessions

public void saveAllSessions()
                     throws IndexingException
Description copied from interface: SearchService
Saves all the pending sessions.

This is useful when using document batch size greater than 1 since if the amount of documents indexed are not an exact multiple of the document batch size then one might want to flush right now on demande the remaning resources in sessions before the next window size is reached.

Specified by:
saveAllSessions in interface SearchService
Throws:
IndexingException

reindexAll

@Deprecated
public void reindexAll(java.lang.String repoName,
                                  java.lang.String path,
                                  boolean fulltext)
                throws IndexingException
Deprecated. 

Description copied from interface: SearchService
Performs a full reindexing of the Nuxeo core repository given a Nuxeo core repository name and a path.

If path is null then the reindexing will be done from the root of the repository (i.e : "/").

Specified by:
reindexAll in interface SearchService
Parameters:
repoName - the Nuxeo Core repository name.
fulltext - whether or not we want to index fulltext.
Throws:
IndexingException

getActiveIndexingTasks

public int getActiveIndexingTasks()
Description copied from interface: SearchService
Returns the number of running indexing tasks.

Specified by:
getActiveIndexingTasks in interface SearchService
Returns:
the number of actively running indexing tasks

getTotalCompletedIndexingTasks

public long getTotalCompletedIndexingTasks()
Description copied from interface: SearchService
Returns the total number of completed indexing tasks.

If you want to use this API for monitoring purpose, you should be aware that the total number of indexing tasks is reinitialized when the component is loaded only. Thus you should keep track of this value before performing your indexing operation you want to keep track of.

Specified by:
getTotalCompletedIndexingTasks in interface SearchService
Returns:
the total number of commpleted indexing tasks.

isReindexingAll

public boolean isReindexingAll()
Description copied from interface: SearchService
Is the search service reindexing the while indexes?

Specified by:
isReindexingAll in interface SearchService
Returns:
a flag

setReindexingAll

public void setReindexingAll(boolean flag)
Description copied from interface: SearchService
Reindex all setter.

Specified by:
setReindexingAll in interface SearchService
Parameters:
flag - bool flag

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.