org.modeshape.search.lucene
Class AbstractLuceneSearchEngine.AbstractLuceneProcessor<WorkspaceType extends SearchEngineWorkspace,SessionType extends AbstractLuceneSearchEngine.WorkspaceSession>

java.lang.Object
  extended by org.modeshape.graph.request.processor.RequestProcessor
      extended by org.modeshape.graph.search.SearchEngineProcessor
          extended by org.modeshape.search.lucene.AbstractLuceneSearchEngine.AbstractLuceneProcessor<WorkspaceType,SessionType>
Type Parameters:
SessionType - the type of session
WorkspaceType - the type of workspace
Direct Known Subclasses:
LuceneSearchProcessor
Enclosing class:
AbstractLuceneSearchEngine<WorkspaceType extends SearchEngineWorkspace,ProcessorType extends SearchEngineProcessor>

protected abstract static class AbstractLuceneSearchEngine.AbstractLuceneProcessor<WorkspaceType extends SearchEngineWorkspace,SessionType extends AbstractLuceneSearchEngine.WorkspaceSession>
extends SearchEngineProcessor

Abstract SearchEngineProcessor implementation for the AbstractLuceneSearchEngine.


Nested Class Summary
protected  class AbstractLuceneSearchEngine.AbstractLuceneProcessor.QueryFactory
           
 
Nested classes/interfaces inherited from class org.modeshape.graph.request.processor.RequestProcessor
RequestProcessor.LocationWithDepth
 
Field Summary
protected  DateTimeFactory dateFactory
           
protected  Logger logger
           
protected  NameFactory nameFactory
           
protected  PathFactory pathFactory
           
protected  PropertyFactory propertyFactory
           
protected  boolean readOnly
           
protected  ValueFactory<String> stringFactory
           
protected  TypeSystem typeSystem
           
protected  UuidFactory uuidFactory
           
protected  ValueFactories valueFactories
           
protected  AbstractSearchEngine.Workspaces<WorkspaceType> workspaces
           
 
Fields inherited from class org.modeshape.graph.search.SearchEngineProcessor
rollback
 
Constructor Summary
protected AbstractLuceneSearchEngine.AbstractLuceneProcessor(String sourceName, ExecutionContext context, AbstractSearchEngine.Workspaces<WorkspaceType> workspaces, Observer observer, DateTime now, boolean readOnly)
           
 
Method Summary
protected  org.apache.lucene.search.Query andQueries(org.apache.lucene.search.Query first, org.apache.lucene.search.Query second)
           
protected  void commit()
          Subclasses should implement this method to commit and save any work that has been done with this processor.
protected abstract  SessionType createSessionFor(WorkspaceType workspace)
           
protected  Property deserializeProperty(String propertyString)
           
protected abstract  String fullTextFieldName(String propertyName)
          Create the field name that will be used to store the full-text searchable property values.
protected  SessionType getSessionFor(Request request, String workspaceName)
           
protected  SessionType getSessionFor(Request request, String workspaceName, boolean createIfMissing)
           
protected  Collection<SessionType> getSessions()
           
protected  WorkspaceType getWorkspace(Request request, String workspaceName, boolean createIfMissing)
           
protected  WorkspaceType getWorkspace(String workspaceName, boolean createIfMissing)
           
 boolean hasChanges()
          Return whether this session made changes to the indexed state.
 String pathAsString(Path path)
           
 void process(AccessQueryRequest request)
          Process a request to query a workspace with an access query, which is is a low-level atomic query that is part of a larger, planned query.
protected  AbstractLuceneSearchEngine.AbstractLuceneProcessor.QueryFactory queryFactory(AbstractLuceneSearchEngine.WorkspaceSession session, Map<String,Object> variables)
           
protected  void rollback()
          Subclasses should implement this method to throw away any work that has been done with this processor.
protected  String serializeProperty(Property property)
           
 
Methods inherited from class org.modeshape.graph.search.SearchEngineProcessor
close, markForRollback
 
Methods inherited from class org.modeshape.graph.request.processor.RequestProcessor
absoluteMaximumDepthForBranchReads, completeRequest, getChanges, getDefaultCachePolicy, getExecutionContext, getNowInUtc, getSourceName, includeChildrenInSubgraph, notifyObserverOfChanges, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, processUnknownRequest, recordChange, setCacheableInfo, setCacheableInfo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

readOnly

protected final boolean readOnly

valueFactories

protected final ValueFactories valueFactories

stringFactory

protected final ValueFactory<String> stringFactory

dateFactory

protected final DateTimeFactory dateFactory

pathFactory

protected final PathFactory pathFactory

uuidFactory

protected final UuidFactory uuidFactory

nameFactory

protected final NameFactory nameFactory

typeSystem

protected final TypeSystem typeSystem

propertyFactory

protected final PropertyFactory propertyFactory

workspaces

protected final AbstractSearchEngine.Workspaces<WorkspaceType extends SearchEngineWorkspace> workspaces

logger

protected final Logger logger
Constructor Detail

AbstractLuceneSearchEngine.AbstractLuceneProcessor

protected AbstractLuceneSearchEngine.AbstractLuceneProcessor(String sourceName,
                                                             ExecutionContext context,
                                                             AbstractSearchEngine.Workspaces<WorkspaceType> workspaces,
                                                             Observer observer,
                                                             DateTime now,
                                                             boolean readOnly)
Method Detail

createSessionFor

protected abstract SessionType createSessionFor(WorkspaceType workspace)

commit

protected void commit()
Subclasses should implement this method to commit and save any work that has been done with this processor.

Specified by:
commit in class SearchEngineProcessor
See Also:
SearchEngineProcessor.commit()

rollback

protected void rollback()
Subclasses should implement this method to throw away any work that has been done with this processor.

Specified by:
rollback in class SearchEngineProcessor
See Also:
SearchEngineProcessor.rollback()

getWorkspace

protected WorkspaceType getWorkspace(String workspaceName,
                                     boolean createIfMissing)

getWorkspace

protected WorkspaceType getWorkspace(Request request,
                                     String workspaceName,
                                     boolean createIfMissing)

getSessionFor

protected SessionType getSessionFor(Request request,
                                    String workspaceName)

getSessionFor

protected SessionType getSessionFor(Request request,
                                    String workspaceName,
                                    boolean createIfMissing)

getSessions

protected Collection<SessionType> getSessions()

serializeProperty

protected final String serializeProperty(Property property)

deserializeProperty

protected final Property deserializeProperty(String propertyString)

fullTextFieldName

protected abstract String fullTextFieldName(String propertyName)
Create the field name that will be used to store the full-text searchable property values.

Parameters:
propertyName - the name of the property; may not null
Returns:
the field name for the full-text searchable property values; never null

hasChanges

public boolean hasChanges()
Return whether this session made changes to the indexed state.

Returns:
true if change were made, or false otherwise

pathAsString

public String pathAsString(Path path)

process

public void process(AccessQueryRequest request)
Process a request to query a workspace with an access query, which is is a low-level atomic query that is part of a larger, planned query.

The default implementation of this method behaves as though the implementation does not support queries by setting an error on the request

Some kinds of constraints are not easily pushed down to Lucene as are of a Lucene Query, and instead are applied by filtering the results. For example, a FullTextSearchScore applies to the score of the tuple, which cannot be (easily?) applied as a Query.

Therefore, each of the AND-ed constraints of the query are evaluated separately. After all, each of the tuples returned by the planned query must satisfy all of the AND-ed constraints. Or, to put it another way, if a tuple does not satisfy one of the AND-ed constraints, the tuple should not be included in the query results.

Logically, any AND-ed criteria that cannot be pushed down to Lucene can of course be applied as a filter on the results. Thus, each AND-ed constraint is processed to first determine if it can be represented as a Lucene query; all other AND-ed constraints must be handled as a results filter. Since most queries will likely use one or more simple constraints AND-ed together, this approach will likely work very well.

The only hairy case is when any AND-ed constraint is actually an OR-ed combination of multiple constraints of which at least one cannot be pushed down to Lucene. In this case, the entire AND-ed constraint must be treated as a results filter (even if many of those constraints that make up the OR-ed constraint can be pushed down). Hopefully, this will not be a common case in actual queries.

Overrides:
process in class RequestProcessor
Parameters:
request - the request
See Also:
RequestProcessor.process(org.modeshape.graph.request.AccessQueryRequest)

andQueries

protected org.apache.lucene.search.Query andQueries(org.apache.lucene.search.Query first,
                                                    org.apache.lucene.search.Query second)

queryFactory

protected AbstractLuceneSearchEngine.AbstractLuceneProcessor.QueryFactory queryFactory(AbstractLuceneSearchEngine.WorkspaceSession session,
                                                                                       Map<String,Object> variables)


Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.