Nuxeo Enterprise Platform 5.1

org.nuxeo.ecm.core.search.backend.compass
Class CompassBackend

java.lang.Object
  extended by org.nuxeo.runtime.model.DefaultComponent
      extended by org.nuxeo.ecm.core.search.api.backend.impl.AbstractSearchEngineBackend
          extended by org.nuxeo.ecm.core.search.backend.compass.CompassBackend
All Implemented Interfaces:
Serializable, SearchEngineBackend, Adaptable, Component, Extensible

public class CompassBackend
extends AbstractSearchEngineBackend

Compass search engine backend implementation.

Author:
Georges Racinet
See Also:
Serialized Form

Field Summary
protected  Compass compass
           
protected  ConnectionConf connectionConf
           
protected  SearchServiceInternals searchService
           
protected  Map sessions
           
 
Fields inherited from class org.nuxeo.ecm.core.search.api.backend.impl.AbstractSearchEngineBackend
configurationFileName, name, supportedAnalyzers, supportedFieldTypes
 
Constructor Summary
CompassBackend()
           
CompassBackend(String name)
           
CompassBackend(String name, String configurationFileName)
           
 
Method Summary
protected static Resource buildResource(CompassSession session, ResourceBuilder builder, ResolvedResource iResource, List<ResolvedData> commonData, String joinIdName, String joinIdValue, ACP acp)
          The main Resource builder, called by index().
protected  ResultItem buildResultItem(Resource r)
          Converts a Resource, typically from the Compass Results to a DocumentResultItem.
protected  ResultSet buildResultSet(CompassHits compassHits, int offset, int range, SQLQuery nxqlQuery, SearchPrincipal principal)
           
 void clear()
          Clear all the indexes.
 void closeSession(String sid)
          Closes a search service session given its session id.
protected  NativeQuery convertToNativeQuery(ComposedNXQuery query)
           
protected  Compass createCompass()
           
 SearchServiceSession createSession()
          Opens a new session.
 void deleteAggregatedResources(String key)
          Deletes an index given an aggregated resources key
 void deleteAtomicResource(String key)
          Deletes an atomic resource given its key.
protected  Serializable extractAtomicProperty(Property prop, String sValue, IndexableResourceDataConf dataConf)
          Extracts a property from the result resource.
static String getAlias(ResolvedResource resource)
          TODO change this to an extension point.
protected  Compass getCompass()
          Builds the shared thread-safe compass object using the standard configuration file compass.cfg.xml.
protected  String getConnectionString()
           
protected  int getIndexingDocBatchSize()
           
 void index(ResolvedResources resources)
          Creates Compass resources from Search Service's resources.
protected  void index(ResolvedResources resources, CompassBackendSession session)
           
protected  void initSearchService()
           
protected  boolean isBoundToIndexingThread()
           
 void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
           
 void saveAllSessions()
          Save all pending sessions.
 ResultSet searchQuery(CompassNativeQuery cnQuery, int offset, int range)
           
 ResultSet searchQuery(ComposedNXQuery cQuery, int offset, int range)
          Searches results given an NXQL query.
 ResultSet searchQuery(NativeQuery nativeQuery, int offset, int range)
          Searches results given a native query.
 ResultSet searchQuery(NativeQueryString queryString, int offset, int range)
          Searches results given a backened specific native query string.
 ResultSet searchQuery(SQLQuery query, SearchPrincipal principal, int offset, int range)
           
 
Methods inherited from class org.nuxeo.ecm.core.search.api.backend.impl.AbstractSearchEngineBackend
getConfigurationFileName, getName, getSupportedAnalyzersFor, getSupportedFieldTypes, setConfigurationFileName, setName
 
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, deactivate, getAdapter, registerExtension, unregisterContribution, unregisterExtension
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compass

protected Compass compass

searchService

protected SearchServiceInternals searchService

connectionConf

protected ConnectionConf connectionConf

sessions

protected final Map sessions
Constructor Detail

CompassBackend

public CompassBackend()

CompassBackend

public CompassBackend(String name)

CompassBackend

public CompassBackend(String name,
                      String configurationFileName)
Method Detail

initSearchService

protected void initSearchService()

getCompass

protected Compass getCompass()
Builds the shared thread-safe compass object using the standard configuration file compass.cfg.xml.

Returns:
shared thread-safe compass object

buildResource

protected static Resource buildResource(CompassSession session,
                                        ResourceBuilder builder,
                                        ResolvedResource iResource,
                                        List<ResolvedData> commonData,
                                        String joinIdName,
                                        String joinIdValue,
                                        ACP acp)
                                 throws IndexingException
The main Resource builder, called by index(). Can use a given builder to add properties or start with a fresh one which as the effect to make a separate resource.

Parameters:
session -
builder -
iResource -
commonData -
joinIdName -
joinIdValue -
acp - ACP of the indexed document
Returns:
Throws:
CompassException
IndexingException

getAlias

public static String getAlias(ResolvedResource resource)
TODO change this to an extension point. For example we can't even use constants here since we don't want to introduce dependencies to, e.g, nuxeo-platform-relations-search

Parameters:
resource -
Returns:

index

protected void index(ResolvedResources resources,
                     CompassBackendSession session)
              throws IndexingException
Throws:
IndexingException

index

public void index(ResolvedResources resources)
           throws IndexingException
Creates Compass resources from Search Service's resources.

All schema resources get merged as a single Compass Resource and gets the joining id as Compass id.

Each resource of a different kind gives rise to a Compass Resource, its own id being used as Compass id.

It's quite possible that Compass could do a better join of handling joins etc by its own concept of MultiResource.

Parameters:
resources - : ResolvedResources instance.
Throws:
IndexingException

deleteAggregatedResources

public void deleteAggregatedResources(String key)
                               throws IndexingException
Description copied from interface: SearchEngineBackend
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()

Parameters:
key - : aggregated resources key.
Throws:
IndexingException

clear

public void clear()
           throws IndexingException
Description copied from interface: SearchEngineBackend
Clear all the indexes.

Throws:
IndexingException

searchQuery

public ResultSet searchQuery(NativeQueryString queryString,
                             int offset,
                             int range)
                      throws SearchException,
                             QueryException
Description copied from interface: SearchEngineBackend
Searches results given a backened specific native query string.

Parameters:
queryString - : a backened specific native query string wrapper
offset - pagination start
range - pagination stop
Returns:
a result set instance
Throws:
SearchException
QueryException

searchQuery

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

Parameters:
cQuery - : a native NXP query
offset - pagination start
range - number of results.
Returns:
a result set instance
Throws:
SearchException - if an error occured while performing the search
QueryException - if the query is invalid or unsupported

searchQuery

public ResultSet searchQuery(SQLQuery query,
                             SearchPrincipal principal,
                             int offset,
                             int range)
                      throws SearchException,
                             QueryException
Throws:
SearchException
QueryException

searchQuery

public ResultSet searchQuery(CompassNativeQuery cnQuery,
                             int offset,
                             int range)
                      throws SearchException,
                             QueryException
Throws:
SearchException
QueryException

extractAtomicProperty

protected Serializable extractAtomicProperty(Property prop,
                                             String sValue,
                                             IndexableResourceDataConf dataConf)
                                      throws SearchException
Extracts a property from the result resource.

For multiple properties, this will be actually one of the elements. Same for complex properties.

For non string properties, the implementation tries first to get the value through Compass and else falls back to java deserialization.

Throws:
SearchException

buildResultItem

protected ResultItem buildResultItem(Resource r)
                              throws SearchException
Converts a Resource, typically from the Compass Results to a DocumentResultItem.

Parameters:
r - Input Resource
Returns:
A DocumentResultItem
Throws:
SearchException

buildResultSet

protected ResultSet buildResultSet(CompassHits compassHits,
                                   int offset,
                                   int range,
                                   SQLQuery nxqlQuery,
                                   SearchPrincipal principal)
                            throws SearchException
Throws:
SearchException

searchQuery

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

Parameters:
nativeQuery - : a backened specific native query wrapper.
offset - pagination start
range - pagination stop
Returns:
a result set instance
Throws:
SearchException - if an error occured while performing the search
QueryException - if the query is invalid or unsupported

deleteAtomicResource

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

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

Parameters:
key - : atomic resource key
Throws:
IndexingException

convertToNativeQuery

protected NativeQuery convertToNativeQuery(ComposedNXQuery query)
                                    throws SearchException
Throws:
SearchException

getConnectionString

protected String getConnectionString()

registerContribution

public void registerContribution(Object contribution,
                                 String extensionPoint,
                                 ComponentInstance contributor)
Overrides:
registerContribution in class AbstractSearchEngineBackend

closeSession

public void closeSession(String sid)
Description copied from interface: SearchEngineBackend
Closes a search service session given its session id.


createSession

public SearchServiceSession createSession()
Description copied from interface: SearchEngineBackend
Opens a new session.

Returns:
a new backend session id

createCompass

protected Compass createCompass()

isBoundToIndexingThread

protected boolean isBoundToIndexingThread()

getIndexingDocBatchSize

protected int getIndexingDocBatchSize()

saveAllSessions

public void saveAllSessions()
                     throws IndexingException
Description copied from interface: SearchEngineBackend
Save all pending sessions.

Throws:
IndexingException

Nuxeo Enterprise Platform 5.1

Copyright ? 2007 Nuxeo SAS. All Rights Reserved.