thinkmap.server
Class DataSourceIndex

java.lang.Object
  extended by thinkmap.server.DataSourceIndex
All Implemented Interfaces:
EventListener, IContextListener, JSONSerializable

public class DataSourceIndex
extends Object
implements IContextListener, JSONSerializable

The <index> tag is used to add a full text index to a Thinkmap datasource.

Version:
$Revision $

Field Summary
static int COMPACT
           
static int DAY
           
static int HOUR
           
static int MILLISECOND
           
static int MINUTE
           
static int MONTH
           
static int SECOND
           
protected  String[] stopWords
           
protected  SearchWrapper wrapper
           
static int YEAR
           
 
Constructor Summary
DataSourceIndex(ThinkmapServerApplication app)
           
 
Method Summary
protected  void configureIndex(Indexer indexer)
           
 void contextDestroyed(IThinkmapContext itc)
          Called when the given context has been destroyed.
 void contextInitializing(IThinkmapContext itc)
          Called when the given context is initializing.
 void contextStarting(IThinkmapContext itc)
          Called when the given context is starting.
 void contextStopping(IThinkmapContext itc)
          Called when the given context is stopping.
 IThinkmapContext getContext()
           
 int getDateResolution()
          Deprecated. 
 int getDocumentCount()
          Gets the number of documents in the index.
 int getDocumentsProcessed()
          Gets the number of documents that have been processed so far while the indexer is indexing.
 String getIndexInterval()
          Gets the indexing interval.
 File getIndexLocation()
          Gets the directory that holds the full text index.
 Date getLastIndexTime()
          Gets the last time this index was re-indexed.
 Date getNextIndexTime()
          Returns the next time this index will be re-indexed, or null if there is no indexInterval set.
 long getProcessingTime()
          Get the number of milliseconds that have elapsed since the start of indexing, or 0 if the indexer is not running.
 String getStatus()
          Get a human-readable description of the status of the indexer.
 Element getStatusXML(Document doc)
          Add XML for this DataSourceIndex
protected  File getTempDir()
           
protected  SearchWrapper getWrapper()
           
 boolean isIndexing()
          Returns true if this index is currently indexing.
 void setConfig(ThinkmapConfig config)
           
 void setDateResolution(int dateResolution)
          Deprecated. 
 void setIndexId(String indexId)
          Sets the "id" of this index.
 void setIndexInterval(String cronSpec)
          Set the indexing interval using a "cron-like" specification which is a number of fields separated by whitespace.
 void setIndexOnStart(boolean b)
          If set to true, the datasource will be indexed on startup if no full-text index exists.
 void setIndexRoot(File f)
          Sets the full path to the directory that will be used to store this full text index.
 void setStopWords(String[] words)
          Set the list of words that the full-text index should ignore.
 void startIndexing()
          Starts the process of reindexing in another thread.
 void stopIndexing()
          Stops the indexer if it is currently running.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

YEAR

public static final int YEAR
See Also:
Constant Field Values

MONTH

public static final int MONTH
See Also:
Constant Field Values

DAY

public static final int DAY
See Also:
Constant Field Values

HOUR

public static final int HOUR
See Also:
Constant Field Values

MINUTE

public static final int MINUTE
See Also:
Constant Field Values

SECOND

public static final int SECOND
See Also:
Constant Field Values

MILLISECOND

public static final int MILLISECOND
See Also:
Constant Field Values

COMPACT

public static final int COMPACT
See Also:
Constant Field Values

stopWords

protected String[] stopWords

wrapper

protected SearchWrapper wrapper
Constructor Detail

DataSourceIndex

public DataSourceIndex(ThinkmapServerApplication app)
Method Detail

setConfig

public void setConfig(ThinkmapConfig config)

contextInitializing

public void contextInitializing(IThinkmapContext itc)
                         throws Exception
Description copied from interface: IContextListener
Called when the given context is initializing. Listeners should construct and configure objects that depend on the context at this time. This method will only be called once per context.

Specified by:
contextInitializing in interface IContextListener
Parameters:
itc - the context that is initializing
Throws:
Exception - if an error occurs while processing this event.

getWrapper

protected SearchWrapper getWrapper()

getTempDir

protected File getTempDir()
                   throws IOException
Throws:
IOException

configureIndex

protected void configureIndex(Indexer indexer)

contextStarting

public void contextStarting(IThinkmapContext itc)
Description copied from interface: IContextListener
Called when the given context is starting. All objects that depend on the context should have been initialized before this method is called. Listeners should start any services they offer at this time. A context may be started, stopped, and started again many times.

Specified by:
contextStarting in interface IContextListener
Parameters:
itc - the context that is starting

contextStopping

public void contextStopping(IThinkmapContext itc)
Description copied from interface: IContextListener
Called when the given context is stopping. Listeners should stop any services they offer at this time.

Specified by:
contextStopping in interface IContextListener
Parameters:
itc - the context that is starting

contextDestroyed

public void contextDestroyed(IThinkmapContext itc)
Description copied from interface: IContextListener
Called when the given context has been destroyed. Listeners should dispose and de-register objects that depend on the context at this time. This method will only be called once per context.

Specified by:
contextDestroyed in interface IContextListener
Parameters:
itc - the context that is being destroyed

setIndexRoot

public void setIndexRoot(File f)
Sets the full path to the directory that will be used to store this full text index.

Parameters:
f - The full path to the directory that will be used to store this full text index.

setIndexId

public void setIndexId(String indexId)
Sets the "id" of this index. Indicies that have the same indexroot and same id will be shared between datasources. This allows you to share a full-text index between multiple Thinkmap Server ".tas" files. The default is null, which means that the index id will be constructed automatically from the URI of the enclosing ".tas" file.

Parameters:
indexId - the "id" of this index.

setIndexInterval

public void setIndexInterval(String cronSpec)
Set the indexing interval using a "cron-like" specification which is a number of fields separated by whitespace. The default is null, which means that re-indexing must be triggered manually.

Here is the format of the fields:

field allowed values
second 0-59
minute 0-59
hour 0-23
day of month 1-31
month 0-11 (or names, see below)
day of week 0-6 (0 is Sun, or use names)

A field may be an asterisk (*), which always stands for "first-last".

Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclu- sive. For example, 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10 and 11.

Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples: "1,2,5,9", "0-4,8-12".

Step values can be used in conjunction with ranges. Fol- lowing a range with "/#" specifies skips of the number's value through the range. For example, ``0-23/2'' can be used in the hours field to specify execution every other hour (the alternative is to use "0,2,4,6,8,10,12,14,16,18,20,22"). Steps are also permitted after an asterisk, so if you want to say "every two hours", just use a "/2" after an "*".

Names can also be used for the "month" and "day of week" fields. Use the first three letters of the particular day or month (case doesn't matter).

Examples:

every five minutes after midnight, every day:
"0 5 0 * * *"
2:15pm on the first of every month:
"0 15 14 1 * *"
at 10pm on weekdays:
"0 0 22 * * mon-fri"
at 5 minutes after 4am every sunday
"0 5 4 * * sun"

Parameters:
cronSpec - the indexing interval using a "cron-like" specification

getIndexInterval

public String getIndexInterval()
Gets the indexing interval.

Returns:
the indexing interval, or null

getContext

public IThinkmapContext getContext()

setDateResolution

@Deprecated
public void setDateResolution(int dateResolution)
Deprecated. 


getDateResolution

@Deprecated
public int getDateResolution()
Deprecated. 


setIndexOnStart

public void setIndexOnStart(boolean b)
If set to true, the datasource will be indexed on startup if no full-text index exists.

Parameters:
b - true if the datasource will be indexed on startup.

getIndexLocation

public File getIndexLocation()
Gets the directory that holds the full text index.

Returns:
the directory that holds the full text index.

isIndexing

public boolean isIndexing()
Returns true if this index is currently indexing.

Returns:
true if this index is currently indexing.

setStopWords

public void setStopWords(String[] words)
Set the list of words that the full-text index should ignore. The default list is "a,an,and,are,as,at,be,but,by,for,if,in,into,is,it,no,not,of,on,or,such,that,the,their,then,there,these,they,this,to,was,will,with"

Parameters:
words - the list of words that the index should ignore.

getNextIndexTime

public Date getNextIndexTime()
Returns the next time this index will be re-indexed, or null if there is no indexInterval set.

Returns:
the next time this index will be re-indexed, or null

getLastIndexTime

public Date getLastIndexTime()
Gets the last time this index was re-indexed.

Returns:
the last time this index was re-indexed.

startIndexing

public void startIndexing()
Starts the process of reindexing in another thread. If the indexer is already running, this has no effect.


stopIndexing

public void stopIndexing()
Stops the indexer if it is currently running.


getDocumentCount

public int getDocumentCount()
Gets the number of documents in the index.

Returns:
the number of documents in the index.

getDocumentsProcessed

public int getDocumentsProcessed()
Gets the number of documents that have been processed so far while the indexer is indexing.

Returns:
number of documents that have been processed so far

getProcessingTime

public long getProcessingTime()
Get the number of milliseconds that have elapsed since the start of indexing, or 0 if the indexer is not running.

Returns:
the number of milliseconds that have elapsed since the start of indexing.

getStatus

public String getStatus()
Get a human-readable description of the status of the indexer.

Returns:

getStatusXML

public Element getStatusXML(Document doc)
Add XML for this DataSourceIndex



Copyright © 2013 Thinkmap, Inc. All Rights Reserved.