org.mmbase.module.lucene
Class Lucene

java.lang.Object
  extended by org.mmbase.util.functions.FunctionProvider
      extended by org.mmbase.util.functions.DescribedFunctionProvider
          extended by org.mmbase.module.Module
              extended by org.mmbase.module.ReloadableModule
                  extended by org.mmbase.module.lucene.Lucene
All Implemented Interfaces:
Descriptor, EventListener, IdEventListener, NodeEventListener, RelationEventListener, SystemEventListener, AssignmentEvents.Listener

public class Lucene
extends ReloadableModule
implements NodeEventListener, RelationEventListener, IdEventListener, AssignmentEvents.Listener, SystemEventListener

This is the implementation of a 'Lucene' module. It's main job is to bootstrap mmbase lucene indexing, and provide some functions to give access to lucene functionality in an MMBase way.

Version:
$Id: Lucene.java 42347 2010-05-31 15:16:14Z michiel $
Author:
Pierre van Rooden, Michiel Meeuwissen

Nested Class Summary
 class Lucene.Scheduler
          Queue for index operations.
 
Field Summary
protected static Parameter<String> ANALYZER
           
protected  Function<Lucene.Scheduler.Assignment> assignmentFunction
           
protected  AssignmentEvents.Listener assignmentsListener
           
protected static Parameter CLASS
           
protected  Function<Void> clearDirectory
           
protected static Parameter<Boolean> COPY
           
protected  Function<Void> deleteIndexFunction
          This function deletes an indexed entry from an index if the Parameter 'index' has value null, all indexes are iterated over, otherwise the right index is addressed.
protected  Function<String> descriptionFunction
          This function returns the description as configured for a specific index and a specific locale.
static String DTD_LUCENE
           
static String DTD_LUCENE_2_0
           
protected static Parameter<String> EXTRACONSTRAINTS
           
protected static Parameter<String> FIELDS
           
protected static Parameter<String> FILTER
           
protected  Function<Void> fullIndexFunction
          This function starts a full Index of Lucene.
protected  Function<Integer> fullIndexing
           
protected static Parameter<String> IDENTIFIER
           
protected  IdEventListener idListener
           
protected static Parameter<String> INDEX
           
protected  Function<Set<Indexer>> indexerListFunction
          This function returns Set with the names of all configured indexes (ordered alphabeticly)
protected  Function<String> interruptFunction
           
protected  Function<Long> lastFullIndexDurationFunction
           
protected  Function<Date> lastFullIndexFunction
           
protected  Function<Set<String>> listFunction
          This function returns Set with the names of all configured indexes (ordered alphabeticly)
protected static Parameter MACHINES
           
protected static Parameter<Integer> MAX
           
protected  MMBase mmbase
           
static String NAMESPACE_LUCENE
          Most recend namespace
static String NAMESPACE_LUCENE_1_0
           
protected static Parameter<Integer> OFFSET
           
protected static Parameter<String> ONFAIL
           
static String PUBLIC_ID_LUCENE
          Most recent Lucene config DTD
static String PUBLIC_ID_LUCENE_2_0
           
protected  Function<Collection<Lucene.Scheduler.Assignment>> queueFunction
           
protected  Function<Boolean> readOnlyFunction
           
protected  Function<NodeList> searchFunction
          This function starts a search fro a given string.
protected  Function<Integer> searchSizeFunction
          This function returns the size of a query on an index.
protected static Parameter<String> SORTFIELDS
           
protected  Function<String> statusDescriptionFunction
           
protected  Function<Integer> statusFunction
          This function returns the status of the scheduler.
protected  Function<Integer> unAssignFunction
           
protected  Function<Void> updateIndexFunction
          This function can be called through the function framework.
protected static Parameter<String> VALUE
          Parameter constants for Lucene functions.
protected  Function<Void> waitFunction
           
static String XSD_LUCENE_1_0
          But we use XSD now!
 
Fields inherited from class org.mmbase.module.Module
configurationPath, getMaintainerFunction, getVersionFunction, properties, STATE_START_TIME
 
Fields inherited from class org.mmbase.util.functions.DescribedFunctionProvider
description, guiName, name
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions, getFunctions
 
Constructor Summary
Lucene()
           
 
Method Summary
(package private)  MMBaseIndexDefinition createIndexDefinition(Element queryElement, Set<String> allIndexedFieldsSet, boolean storeText, boolean mergeText, String relateFrom, Analyzer analyzer)
          MMBase Queries and sub-queries
static String getAttribute(Element element, String localName)
          Returns the value of a certain attribute, either an unqualified attribute or an attribute that fits in the lucene namespace
protected  Cloud getCloud()
           
 String getDescription()
          Returns the description of this object for the default locale.
static Lucene getLucene()
           
 Searcher getSearcher(String indexName)
           
static boolean hasAttribute(Element element, String localName)
          Returns whether an element has a certain attribute, either an unqualified attribute or an attribute that fits in the lucene namespace
 void init()
          Initializes the module.
 void init(boolean initialWait)
           
static void main(String[] args)
          Main for testing
 void notify(AssignmentEvents.Event event)
           
 void notify(IdEvent event)
           
 void notify(NodeEvent event)
           
 void notify(RelationEvent event)
           
 void notify(SystemEvent systemEvent)
           
protected  void readConfiguration(String resource)
           
 void reload()
          This method should be called when the module should be reloaded.
 void shutdown()
          Shuts down the module.
 
Methods inherited from class org.mmbase.module.ReloadableModule
reloadConfiguration, reloadConfiguration
 
Methods inherited from class org.mmbase.module.Module
addInitParameters, checkModules, getInitParameter, getInitParameter, getInitParameter, getInitParameters, getInitParameters, getMaintainer, getModule, getModule, getModule, getModule, getModuleInfo, getModuleLoader, getModuleReader, getModuleReader, getModules, getState, getStates, getVersion, hasModule, hasStarted, loadInitParameters, loadInitParameters, maintainance, onload, setInitParameter, setMaintainer, setState, setVersion, shutdownModules, startModule, startModules
 
Methods inherited from class org.mmbase.util.functions.DescribedFunctionProvider
getDefaultLocale, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName, setLocalizedDescription, setLocalizedGUIName, setName
 
Methods inherited from class org.mmbase.util.functions.FunctionProvider
addFunction, createParameters, getFunction, getFunctions, getFunctionValue, newFunctionInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PUBLIC_ID_LUCENE_2_0

public static final String PUBLIC_ID_LUCENE_2_0
See Also:
Constant Field Values

DTD_LUCENE_2_0

public static final String DTD_LUCENE_2_0
See Also:
Constant Field Values

PUBLIC_ID_LUCENE

public static final String PUBLIC_ID_LUCENE
Most recent Lucene config DTD

See Also:
Constant Field Values

DTD_LUCENE

public static final String DTD_LUCENE
See Also:
Constant Field Values

XSD_LUCENE_1_0

public static final String XSD_LUCENE_1_0
But we use XSD now!

See Also:
Constant Field Values
To Do:
Support for DTD's can be dropped, it was never released.

NAMESPACE_LUCENE_1_0

public static final String NAMESPACE_LUCENE_1_0
See Also:
Constant Field Values

NAMESPACE_LUCENE

public static final String NAMESPACE_LUCENE
Most recend namespace

See Also:
Constant Field Values

mmbase

protected MMBase mmbase

VALUE

protected static final Parameter<String> VALUE
Parameter constants for Lucene functions.


INDEX

protected static final Parameter<String> INDEX

MACHINES

protected static final Parameter MACHINES

COPY

protected static final Parameter<Boolean> COPY

CLASS

protected static final Parameter CLASS

SORTFIELDS

protected static final Parameter<String> SORTFIELDS

FIELDS

protected static final Parameter<String> FIELDS

ANALYZER

protected static final Parameter<String> ANALYZER

OFFSET

protected static final Parameter<Integer> OFFSET

MAX

protected static final Parameter<Integer> MAX

EXTRACONSTRAINTS

protected static final Parameter<String> EXTRACONSTRAINTS

FILTER

protected static final Parameter<String> FILTER

ONFAIL

protected static final Parameter<String> ONFAIL

IDENTIFIER

protected static final Parameter<String> IDENTIFIER

fullIndexFunction

protected final Function<Void> fullIndexFunction
This function starts a full Index of Lucene. This may take a while. This function can be called through the function framework.


deleteIndexFunction

protected Function<Void> deleteIndexFunction
This function deletes an indexed entry from an index if the Parameter 'index' has value null, all indexes are iterated over, otherwise the right index is addressed.


updateIndexFunction

protected Function<Void> updateIndexFunction
This function can be called through the function framework. It (re)loads the index for a specific item (identified by 'identifier' parameter).


statusFunction

protected Function<Integer> statusFunction
This function returns the status of the scheduler. For possible values see: Lucene.Scheduler


statusDescriptionFunction

protected Function<String> statusDescriptionFunction

assignmentFunction

protected Function<Lucene.Scheduler.Assignment> assignmentFunction

queueFunction

protected Function<Collection<Lucene.Scheduler.Assignment>> queueFunction

waitFunction

protected Function<Void> waitFunction

readOnlyFunction

protected Function<Boolean> readOnlyFunction

listFunction

protected Function<Set<String>> listFunction
This function returns Set with the names of all configured indexes (ordered alphabeticly)


indexerListFunction

protected Function<Set<Indexer>> indexerListFunction
This function returns Set with the names of all configured indexes (ordered alphabeticly)


descriptionFunction

protected Function<String> descriptionFunction
This function returns the description as configured for a specific index and a specific locale.


searchFunction

protected Function<NodeList> searchFunction
This function starts a search fro a given string. This function can be called through the function framework.


searchSizeFunction

protected Function<Integer> searchSizeFunction
This function returns the size of a query on an index.


clearDirectory

protected Function<Void> clearDirectory

fullIndexing

protected Function<Integer> fullIndexing

unAssignFunction

protected Function<Integer> unAssignFunction

interruptFunction

protected Function<String> interruptFunction

lastFullIndexFunction

protected Function<Date> lastFullIndexFunction

lastFullIndexDurationFunction

protected Function<Long> lastFullIndexDurationFunction

idListener

protected final IdEventListener idListener

assignmentsListener

protected final AssignmentEvents.Listener assignmentsListener
Constructor Detail

Lucene

public Lucene()
Method Detail

getLucene

public static Lucene getLucene()

hasAttribute

public static boolean hasAttribute(Element element,
                                   String localName)
Returns whether an element has a certain attribute, either an unqualified attribute or an attribute that fits in the lucene namespace


getAttribute

public static String getAttribute(Element element,
                                  String localName)
Returns the value of a certain attribute, either an unqualified attribute or an attribute that fits in the lucene namespace


notify

public void notify(AssignmentEvents.Event event)
Specified by:
notify in interface AssignmentEvents.Listener

init

public void init()
Description copied from class: Module
Initializes the module. Init must be overridden to read the environment variables it needs.
This method is called by Module.startModule(), which makes sure it is not called more than once. You should not call init() directly, call startModule() instead.

Overrides:
init in class Module

init

public void init(boolean initialWait)

notify

public void notify(SystemEvent systemEvent)
Specified by:
notify in interface SystemEventListener

getCloud

protected Cloud getCloud()

shutdown

public void shutdown()
Description copied from class: Module
Shuts down the module. This method is called by shutdownModules.

Overrides:
shutdown in class Module

reload

public void reload()
Description copied from class: ReloadableModule
This method should be called when the module should be reloaded.

Specified by:
reload in class ReloadableModule

getDescription

public String getDescription()
Description copied from interface: Descriptor
Returns the description of this object for the default locale.

Specified by:
getDescription in interface Descriptor
Overrides:
getDescription in class DescribedFunctionProvider
Returns:
the description as a String

createIndexDefinition

MMBaseIndexDefinition createIndexDefinition(Element queryElement,
                                            Set<String> allIndexedFieldsSet,
                                            boolean storeText,
                                            boolean mergeText,
                                            String relateFrom,
                                            Analyzer analyzer)
MMBase Queries and sub-queries


readConfiguration

protected void readConfiguration(String resource)

getSearcher

public Searcher getSearcher(String indexName)

notify

public void notify(NodeEvent event)
Specified by:
notify in interface NodeEventListener

notify

public void notify(RelationEvent event)
Specified by:
notify in interface RelationEventListener

notify

public void notify(IdEvent event)
Specified by:
notify in interface IdEventListener

main

public static void main(String[] args)
Main for testing



MMBase 2.0-SNAPSHOT - null