Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.profiles.search
Class ProfileSearchManagerImpl

java.lang.Object
  extended by com.jivesoftware.profiles.search.ProfileSearchManagerImpl
All Implemented Interfaces:
JiveManager, ProfileSearchManager

public class ProfileSearchManagerImpl
extends java.lang.Object
implements ProfileSearchManager, JiveManager

Database implementation of ProfileSearchManager using the Lucene search package. Search indexes are stored in the "search/user" subdirectory of jiveHome.


Field Summary
protected static org.apache.lucene.analysis.Analyzer indexerAnalyzer
          The analyzer governs how words are tokenized.
protected static org.apache.lucene.analysis.Analyzer searcherAnalyzer
          The analyzer governs how words are tokenized.
protected static ReadWriteLock searcherLock
           
 
Method Summary
 void addToIndex(User user)
          Adds an individual user to the index.
 void addToIndex(User user, boolean cluster)
           
protected  void addUserToIndex(long userID, org.apache.lucene.index.IndexWriter writer)
          Indexes an individual user.
static void closeSearcherReader()
          Closes the readers used by the searcher to indicate that a change to the index was made.
protected  void deleteUsersFromIndex(long[] entries, org.apache.lucene.index.IndexReader reader)
          Deletes users(s) from the index.
 void destroy()
          Notifies the manager to release any resources that may be holding on too.
 int getAutoIndexInterval()
          Returns the number of minutes that the indexer waits between each update.
 int getCurrentCount()
          Returns the number of entries that have been indexed if an indexing operation is currently active (i.e., ProfileSearchManager.isBusy() returns true).
static ProfileSearchManagerImpl getInstance()
           
 java.util.Date getLastIndexedDate()
          Returns the date that the last update to the index was made.
 int getPercentComplete()
          Returns the percent complete that an indexing operation is if an indexing operation is currently active (i.e., ProfileSearchManager.isBusy() returns true).
static XMLJiveProperties getProperties()
           
 int getTotalCount()
          Returns the total number of entries that are to be indexed if an indexing operation is currently active (i.e., ProfileSearchManager.isBusy() returns true).
 void initialize()
          Initialize the manager.
 boolean isAutoIndexEnabled()
          Returns true if auto indexing is turned on.
 boolean isBusy()
          Returns true if the search manager is currently busy with an search indexing task.
 boolean isEmailVisible()
          Determines whether or not user email addresses are visible when performing a user search.
 boolean isSearchEnabled()
          Returns true if the profile search feature is turned on.
 void optimize()
          Optimizes the underlying search index for maximum speed.
 void rebuildIndex()
          Manually rebuild the entire index.
protected  void removeFromIndex(long userID)
           
 void removeFromIndex(User user)
          Removes an individual user from the index.
 void removeFromIndex(User user, boolean cluster)
           
 org.apache.lucene.search.Hits search(ProfileSearchQuery query)
          Returns the hits that correspond to the search query.
 void setAutoIndexEnabled(boolean enabled)
          Enables or disables auto indexing.
 void setAutoIndexInterval(int minutes)
          Sets the number of minutes that indexer should wait between updating the index.
 void setEmailVisible(boolean emailVisible)
          Determines whether or not user email addresses are visible when performing a user search.
 void setSearchEnabled(boolean searchEnabled)
          Enables or disables the profile search feature.
 void updateIndex()
          Manually update the index to include all new objects since the last update.
protected  void updateIndex(java.util.Date start, java.util.Date end)
          Updates the index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

searcherLock

protected static ReadWriteLock searcherLock

indexerAnalyzer

protected static org.apache.lucene.analysis.Analyzer indexerAnalyzer
The analyzer governs how words are tokenized. We make the analyzer map protected so that the DbQuery class can also reference it as required.


searcherAnalyzer

protected static org.apache.lucene.analysis.Analyzer searcherAnalyzer
The analyzer governs how words are tokenized. There is a seperate analyzer map for searching because searching requires that synonyms be disabled, while indexing requires that they be enabled.

Method Detail

getInstance

public static ProfileSearchManagerImpl getInstance()

isSearchEnabled

public boolean isSearchEnabled()
Description copied from interface: ProfileSearchManager
Returns true if the profile search feature is turned on. When profile search is disabled, other methods serve as no-ops and auto indexing will not occur.

Specified by:
isSearchEnabled in interface ProfileSearchManager
Returns:
true if the search is enabled.

setSearchEnabled

public void setSearchEnabled(boolean searchEnabled)
Description copied from interface: ProfileSearchManager
Enables or disables the profile search feature. When profile search is disabled, other methods serve as no-ops and auto indexing will not occur.

Specified by:
setSearchEnabled in interface ProfileSearchManager
Parameters:
searchEnabled - true to enable the search feature, false to disable.

isEmailVisible

public boolean isEmailVisible()
Description copied from interface: ProfileSearchManager
Determines whether or not user email addresses are visible when performing a user search. If emailVisible is set to false, email addresses will not be displayed on the user search results page, regardless of the user's personal emailVisible setting. If emailVisible is true then email addresses will be displayed only for user's with their personal emailVisible setting equal to true. EmailVisible is true by default.

Specified by:
isEmailVisible in interface ProfileSearchManager

setEmailVisible

public void setEmailVisible(boolean emailVisible)
Description copied from interface: ProfileSearchManager
Determines whether or not user email addresses are visible when performing a user search. If emailVisible is set to false, email addresses will not be displayed on the user search results page, regardless of the user's personal emailVisible setting. If emailVisible is true then email addresses will be displayed only for user's with their personal emailVisible setting equal to true. EmailVisible is true by default.

Specified by:
setEmailVisible in interface ProfileSearchManager
Parameters:
emailVisible - true if user email addresses are visible, false otherwise.

search

public org.apache.lucene.search.Hits search(ProfileSearchQuery query)
Description copied from interface: ProfileSearchManager
Returns the hits that correspond to the search query.

Specified by:
search in interface ProfileSearchManager
Parameters:
query - the profile search query
Returns:
the users that match the search criteria.

initialize

public void initialize()
Description copied from interface: JiveManager
Initialize the manager. It is within this method that it is ok to create, access and/or otherwise use external classes (including caches). Until this method is called implementation should not access any external classes that could possibly either access one of the main Factory classes or any caches since doing so can cause deadlocks and possible clustering issues during startup.

This method is used internally by Jive during application startup and should not be called during normal usage of the class.

Specified by:
initialize in interface JiveManager

destroy

public void destroy()
Description copied from interface: JiveManager
Notifies the manager to release any resources that may be holding on too. This could also be used to clear out the managers caches, etc.

This method is used internally by Jive during application startup and should not be called during normal usage of the class.

Specified by:
destroy in interface JiveManager

getProperties

public static XMLJiveProperties getProperties()

getAutoIndexInterval

public int getAutoIndexInterval()
Description copied from interface: ProfileSearchManager
Returns the number of minutes that the indexer waits between each update.

Specified by:
getAutoIndexInterval in interface ProfileSearchManager
Returns:
the number of minutes between automatic index updates.

setAutoIndexInterval

public void setAutoIndexInterval(int minutes)
Description copied from interface: ProfileSearchManager
Sets the number of minutes that indexer should wait between updating the index.

Specified by:
setAutoIndexInterval in interface ProfileSearchManager
Parameters:
minutes - the number of minutes between automatic index updates.

getLastIndexedDate

public java.util.Date getLastIndexedDate()
Description copied from interface: ProfileSearchManager
Returns the date that the last update to the index was made.

Specified by:
getLastIndexedDate in interface ProfileSearchManager
Returns:
the date the last index update was made.

isBusy

public boolean isBusy()
Description copied from interface: ProfileSearchManager
Returns true if the search manager is currently busy with an search indexing task. When busy, calls to index operations such as ProfileSearchManager.rebuildIndex() will do nothing. If you'd like to query the status of the indexing operation while the manager is busy, use the ProfileSearchManager.getPercentComplete() method.

Specified by:
isBusy in interface ProfileSearchManager
Returns:
true if the search manager is currently busy with an index maintenance task.

getPercentComplete

public int getPercentComplete()
Description copied from interface: ProfileSearchManager
Returns the percent complete that an indexing operation is if an indexing operation is currently active (i.e., ProfileSearchManager.isBusy() returns true). Valid percentages returned are from 0 to 100. If no indexing operation is active, this method will return -1.

Specified by:
getPercentComplete in interface ProfileSearchManager
Returns:
the percent complete that the currently active index operation is.

getTotalCount

public int getTotalCount()
Description copied from interface: ProfileSearchManager
Returns the total number of entries that are to be indexed if an indexing operation is currently active (i.e., ProfileSearchManager.isBusy() returns true).

Specified by:
getTotalCount in interface ProfileSearchManager
Returns:
the total number of entries that are to be indexed

getCurrentCount

public int getCurrentCount()
Description copied from interface: ProfileSearchManager
Returns the number of entries that have been indexed if an indexing operation is currently active (i.e., ProfileSearchManager.isBusy() returns true).

Specified by:
getCurrentCount in interface ProfileSearchManager
Returns:
the number of entries that have been indexed

isAutoIndexEnabled

public boolean isAutoIndexEnabled()
Description copied from interface: ProfileSearchManager
Returns true if auto indexing is turned on. When auto indexing is on, it will update the search index at the interval specified by the setUpdateInterval method.

Specified by:
isAutoIndexEnabled in interface ProfileSearchManager
Returns:
true if auto indexing is turned on.

setAutoIndexEnabled

public void setAutoIndexEnabled(boolean enabled)
Description copied from interface: ProfileSearchManager
Enables or disables auto indexing. When auto indexing is on, it will update the search index at the interval specified by the setUpdateInterval method.

Specified by:
setAutoIndexEnabled in interface ProfileSearchManager
Parameters:
enabled - true to turn auto indexing on, false to turn it off.

addToIndex

public void addToIndex(User user)
Description copied from interface: ProfileSearchManager
Adds an individual user to the index. This method is useful for doing real-time indexing. However, for maximum posting speed this method can be ignored. In that case, the automatic indexer will pick up all new entries at the next index interval.

Specified by:
addToIndex in interface ProfileSearchManager
Parameters:
user - the user to add to the index.

addToIndex

public void addToIndex(User user,
                       boolean cluster)

removeFromIndex

public void removeFromIndex(User user)
Description copied from interface: ProfileSearchManager
Removes an individual user from the index.

Specified by:
removeFromIndex in interface ProfileSearchManager
Parameters:
user - the user to remove from the index.

removeFromIndex

public void removeFromIndex(User user,
                            boolean cluster)

removeFromIndex

protected void removeFromIndex(long userID)

updateIndex

public void updateIndex()
Description copied from interface: ProfileSearchManager
Manually update the index to include all new objects since the last update.

Specified by:
updateIndex in interface ProfileSearchManager

rebuildIndex

public void rebuildIndex()
Description copied from interface: ProfileSearchManager
Manually rebuild the entire index. This operation can be slow if the index is large.

Specified by:
rebuildIndex in interface ProfileSearchManager

optimize

public void optimize()
Description copied from interface: ProfileSearchManager
Optimizes the underlying search index for maximum speed. This operation may be CPU intensive so should be performed relatively infrequently. Rebuilding an index should automatically optimize it.

Specified by:
optimize in interface ProfileSearchManager

updateIndex

protected final void updateIndex(java.util.Date start,
                                 java.util.Date end)
Updates the index. It first deletes any objects in the index between the start and end times, and then adds all objects to the index that are between the start and end times.


addUserToIndex

protected final void addUserToIndex(long userID,
                                    org.apache.lucene.index.IndexWriter writer)
Indexes an individual user. This will also index all user profile values. The writer is assumed to be open when passed in and will remain open after the method is done executing.


deleteUsersFromIndex

protected final void deleteUsersFromIndex(long[] entries,
                                          org.apache.lucene.index.IndexReader reader)
                                   throws java.io.IOException
Deletes users(s) from the index.

Throws:
java.io.IOException

closeSearcherReader

public static void closeSearcherReader()
Closes the readers used by the searcher to indicate that a change to the index was made. A new reader will be opened the next time one is requested.


Jive Forums Project Page

Copyright © 1999-2006 Jive Software.