net.grcomputing.opencms.search.lucene
Class SearchHelper

java.lang.Object
  |
  +--net.grcomputing.opencms.search.lucene.SearchHelper
All Implemented Interfaces:
I_XmlConfigConstants

public class SearchHelper
extends java.lang.Object
implements I_XmlConfigConstants

Provides convenience functions for JSPs or external classes that want to provide Lucene search capablilites.

Author:
Matt Butcher mbutcher@grcomputing.net
See Also:
http://grcomputing.net

Field Summary
protected static java.lang.String[] indexedFields
          Fields that get indexed.
 
Fields inherited from interface net.grcomputing.opencms.search.lucene.I_XmlConfigConstants
ATTR_ENABLED, ATTR_LOCATION, ATTR_NAME, ELE_ANALYZER, ELE_CLASS, ELE_DIRECTORIES, ELE_DIRECTORY, ELE_DOC_FACTORIES, ELE_EXTENSION, ELE_FILE_TYPE, ELE_INDEX_DIR, ELE_JSP_DOC_FACTORY, ELE_MERGE_FACTOR, ELE_PAGE_DOC_FACTORY, ELE_PERM_CHECK, ELE_PLAIN_DOC_FACTORY, ELE_PROJECT, ELE_SECTION, ELE_SUBSEARCH, ELE_XML_TEMPLATE_DOC_FACTORY, LUCENE_SEARCH_ELEMENT
 
Constructor Summary
SearchHelper(CmsJspActionElement cms)
          Creates new SearchHelper, getting information out of the main registry.
SearchHelper(CmsObject cmsobject, org.w3c.dom.Element luceneElement)
          Creates new SearchHelper, using the registry provided.
SearchHelper(CmsObject cmsobject, java.lang.String registryPath)
          Creates new SearchHelper, using the registry provided.
 
Method Summary
 Hits doSimpleSearch(java.lang.String term)
          Does a very simple search, running a StopAnalyzer against a search within bodies.
 java.lang.String[] getIndexedFields()
          Returns a list of indexed fields.
 java.lang.String getIndexPath()
          Get the path for the Lucene search index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

indexedFields

protected static java.lang.String[] indexedFields
Fields that get indexed.

See Also:
I_DocumentConstants
Constructor Detail

SearchHelper

public SearchHelper(CmsJspActionElement cms)
             throws CmsException
Creates new SearchHelper, getting information out of the main registry. This is a convenience constructor for JSPs. (The registry is usually found in $TOMCAT_HOME/webapps/opencms/WEB_INF/config/registry.xml)

Throws:
CmsException - if no lucene config info can be found in registry, or if there were problems trying to work with the registry.

SearchHelper

public SearchHelper(CmsObject cmsobject,
                    java.lang.String registryPath)
             throws CmsException
Creates new SearchHelper, using the registry provided. (rather than the default registry).

Throws:
CmsException - if no registry is found, or no lucene config info can be found in registry, or if there were problems trying to work with the registry.

SearchHelper

public SearchHelper(CmsObject cmsobject,
                    org.w3c.dom.Element luceneElement)
Creates new SearchHelper, using the registry provided. (rather than the default registry).

Throws:
CmsException - if no registry is found, or no lucene config info can be found in registry, or if there were problems trying to work with the registry.
Method Detail

getIndexPath

public java.lang.String getIndexPath()
                              throws CmsException
Get the path for the Lucene search index.

Returns:
path to the Lucene index.
Throws:
CmsException - if there is no index element or no data in the index element.

doSimpleSearch

public Hits doSimpleSearch(java.lang.String term)
                    throws CmsException
Does a very simple search, running a StopAnalyzer against a search within bodies.

Returns:
Hits containing lucene Documents
Throws:
CmsException - if search fails or there is a problem getting the the information necessary for a search.

getIndexedFields

public java.lang.String[] getIndexedFields()
Returns a list of indexed fields. NOTE: at this time, this is actually a static array reflecting the fields I_DocumentConstants defines. This will probably change in the future.

Returns:
an array of Strings, each naming a particular field that was indexed.
See Also:
I_DocumentConstants


Copyright © 2003 Matt Butcher of Global Resources for Computing. Reporoduction and modification of this documents are allowed as in accordance with the GPL v2. Refer to COPYING.txt for information on acceptible use