fr.gouv.culture.sdx.search.lucene.query
Class RegexTerms

java.lang.Object
  extended by fr.gouv.culture.sdx.utils.AbstractSdxObject
      extended by fr.gouv.culture.sdx.search.lucene.query.AbstractResponse
          extended by fr.gouv.culture.sdx.search.lucene.query.Terms
              extended by fr.gouv.culture.sdx.search.lucene.query.RegexTerms
All Implemented Interfaces:
Terms, Describable, Encodable, Identifiable, Localizable, SdxObject, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, org.apache.excalibur.xml.sax.XMLizable

public class RegexTerms
extends Terms

A list of terms for a document base filtered against a regular expression. This class optimizes Terms for the lists of terms filtered by a value with or without wildcard. In this case, the class is 10th faster than Terms. This gain comes with the use of a RegexTermEnum.

Since:
SDX v. 2.4.1
Author:
Malo Pichot

Nested Class Summary
 
Nested classes/interfaces inherited from interface fr.gouv.culture.sdx.utils.SdxObject
SdxObject.ConfigurationNode
 
Field Summary
 
Fields inherited from class fr.gouv.culture.sdx.search.lucene.query.Terms
sortCollator, termList
 
Fields inherited from class fr.gouv.culture.sdx.search.lucene.query.AbstractResponse
_count, _hitsPerPage, _nbPages, _searchLocations, HITS_PER_PAGE, HPP_ALL_HITS
 
Fields inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject
_configuration, _context, _description, _encoding, _id, _locale, _logger, _manager, _xmlizable_objects, _xmlLang, isToSaxInitialized
 
Fields inherited from interface fr.gouv.culture.sdx.search.Terms
CLASS_NAME_SUFFIX
 
Fields inherited from interface fr.gouv.culture.sdx.utils.Encodable
DEFAULT_ENCODING
 
Constructor Summary
RegexTerms()
          Creates a list of terms according to a chain with truncation A super.getLog() must be set and then the Terms must be setUp.
 
Method Summary
 java.util.TreeMap getRegexTerms(java.util.BitSet docs)
          Builds a list of terms (as a TreeMap).
 void setField(java.lang.String field)
          Sets the field to this RegexTerms
 void setIndexReader(org.apache.lucene.index.IndexReader reader)
          Sets the IndexReader for this RegexTerms
 void setRegex(java.lang.String value)
          Sets the regular expression that may filter the list of terms
 void setRegexCapabilities(org.apache.lucene.search.regex.RegexCapabilities regexCapabilities)
          Sets the RegexCapabilities to this RegexTerms Sets the RegexCapabilities to this RegexTerms.
 void setSearchLocations(SearchLocations searchLocations)
          Sets the SDX SearchLocations to this RegexTerms Sets the SDX SearchLocations to this RegexTerms.
 void setUp(SearchLocations sLocs, Query sdxQuery, java.lang.String field, java.lang.String value)
          Builds a term list filtered by a Query, and optionally a value.
 void setUp(SearchLocations sLocs, org.apache.lucene.search.Query luceneQuery, java.lang.String field, java.lang.String value)
          Builds a term list filtered by a Lucene Query, and optionally a value.
 void setUp(SearchLocations sLocs, Query sdxQuery, java.lang.String field, java.lang.String value, org.apache.lucene.search.regex.RegexCapabilities regexCapabilities)
          Builds a term list filtered by a SDX Query, and optionally a value.
 void setUp(SearchLocations sLocs, org.apache.lucene.search.Query luceneQuery, java.lang.String field, java.lang.String value, org.apache.lucene.search.regex.RegexCapabilities regexCapabilities)
          Builds a term list filtered by a Lucene Query, and optionally a value.
 void setUp(SearchLocations sLocs, Results sdxResults, java.lang.String field, java.lang.String value)
          Builds a term list filtered by a SDX Results, and optionally a value.
 void setUp(SearchLocations sLocs, java.lang.String field, java.lang.String value)
          Builds a list of terms from a field, optionally filtered by a regular expression.
 void setUp(SearchLocations sLocs, java.lang.String field, java.lang.String value, org.apache.lucene.search.regex.RegexCapabilities regexCapabilities)
          Builds a list of terms from a field, optionally filtered by a regular expression.
 
Methods inherited from class fr.gouv.culture.sdx.search.lucene.query.Terms
countPages, getClassNameSuffix, getDocumentSet, getList, getTerms, getTerms, getTerms, initCollator, setAllHits, setFieldFilter, setHitsPerPage, setUp, setUp, setUp, setUp, setUp, toSAX, toSAX
 
Methods inherited from class fr.gouv.culture.sdx.search.lucene.query.AbstractResponse
count, getHitsPerPage, getNbPages, getSearchLocations, initToSax, initVolatileObjectsToSax, setNbPages
 
Methods inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject
configure, configureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, service, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, verifyConfigurationResources
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fr.gouv.culture.sdx.utils.SdxObject
getLog
 
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled
enableLogging
 
Methods inherited from interface org.apache.avalon.framework.context.Contextualizable
contextualize
 
Methods inherited from interface org.apache.avalon.framework.service.Serviceable
service
 
Methods inherited from interface org.apache.avalon.framework.configuration.Configurable
configure
 
Methods inherited from interface fr.gouv.culture.sdx.utils.Identifiable
getId, setId
 
Methods inherited from interface fr.gouv.culture.sdx.utils.Describable
getDescription, setDescription
 
Methods inherited from interface fr.gouv.culture.sdx.utils.Encodable
getEncoding, setEncoding
 
Methods inherited from interface fr.gouv.culture.sdx.utils.Localizable
getLocale, getXmlLang, setLocale, setXmlLang
 

Constructor Detail

RegexTerms

public RegexTerms()
Creates a list of terms according to a chain with truncation

A super.getLog() must be set and then the Terms must be setUp.

See Also:
AbstractSdxObject.enableLogging(org.apache.avalon.framework.logger.Logger), setUp(fr.gouv.culture.sdx.search.lucene.query.SearchLocations, fr.gouv.culture.sdx.search.lucene.query.Results, java.lang.String, java.lang.String)
Method Detail

setRegexCapabilities

public void setRegexCapabilities(org.apache.lucene.search.regex.RegexCapabilities regexCapabilities)
Sets the RegexCapabilities to this RegexTerms

Sets the RegexCapabilities to this RegexTerms. If the RegexCapabilities passed to the method is null, uses JavaUtilRegexCapabilities

Parameters:
regexCapabilities - The RegexCapabilities to set

setSearchLocations

public void setSearchLocations(SearchLocations searchLocations)
Sets the SDX SearchLocations to this RegexTerms Sets the SDX SearchLocations to this RegexTerms. Throws a warning message when the SearchLocations contains more than one Lucene Reader.

Overrides:
setSearchLocations in class AbstractResponse
Parameters:
searchLocations - The SearchLocations to set.
See Also:
AbstractResponse.setSearchLocations(fr.gouv.culture.sdx.search.lucene.query.SearchLocations)

setField

public void setField(java.lang.String field)
              throws SDXException
Sets the field to this RegexTerms

Parameters:
field - The field to set
Throws:
SDXException

setIndexReader

public void setIndexReader(org.apache.lucene.index.IndexReader reader)
Sets the IndexReader for this RegexTerms

Parameters:
reader - The IndexReader to set

setRegex

public void setRegex(java.lang.String value)
              throws SDXException
Sets the regular expression that may filter the list of terms

Parameters:
value - The regular expression (as a String) to set.
Throws:
SDXException - Throws a SDXException for incorrect regular expression

setUp

public void setUp(SearchLocations sLocs,
                  Results sdxResults,
                  java.lang.String field,
                  java.lang.String value)
           throws SDXException
Builds a term list filtered by a SDX Results, and optionally a value.

Overrides:
setUp in class Terms
Parameters:
searchLocations - The SDX Search Locations object
results - The Results object to extract the Lucene Query
field - The field name.
value - The value (may be null)
Throws:
SDXException

setUp

public void setUp(SearchLocations sLocs,
                  Query sdxQuery,
                  java.lang.String field,
                  java.lang.String value)
           throws SDXException
Builds a term list filtered by a Query, and optionally a value.

Overrides:
setUp in class Terms
Parameters:
searchLocations - The SDX Search Locations object
sdxQuery - The SDX Query object to extract the Lucene Query
field - The field name.
value - The value (may be null)
Throws:
SDXException

setUp

public void setUp(SearchLocations sLocs,
                  Query sdxQuery,
                  java.lang.String field,
                  java.lang.String value,
                  org.apache.lucene.search.regex.RegexCapabilities regexCapabilities)
           throws SDXException
Builds a term list filtered by a SDX Query, and optionally a value.

Parameters:
searchLocations - The SDX Search Locations object.
sdxQuery - The SDX Query.
field - The field name.
value - The value (may be null).
regexCapabilities - The RegexCapabilities.
Throws:
SDXException

setUp

public void setUp(SearchLocations sLocs,
                  org.apache.lucene.search.Query luceneQuery,
                  java.lang.String field,
                  java.lang.String value)
           throws SDXException
Builds a term list filtered by a Lucene Query, and optionally a value.

Overrides:
setUp in class Terms
Parameters:
searchLocations - The SDX Search Locations object.
query - The Lucene Query object
field - The field name.
value - The value (may be null).
Throws:
SDXException

setUp

public void setUp(SearchLocations sLocs,
                  org.apache.lucene.search.Query luceneQuery,
                  java.lang.String field,
                  java.lang.String value,
                  org.apache.lucene.search.regex.RegexCapabilities regexCapabilities)
           throws SDXException
Builds a term list filtered by a Lucene Query, and optionally a value.

Parameters:
searchLocations - The SDX Search Locations object
query - The Lucene Query object.
field - The field name.
value - The value (may be null).
regexCapabilities - The RegexCapabilities.
Throws:
SDXException

setUp

public void setUp(SearchLocations sLocs,
                  java.lang.String field,
                  java.lang.String value)
           throws SDXException
Builds a list of terms from a field, optionally filtered by a regular expression.

Overrides:
setUp in class Terms
Parameters:
The - SearchLocations that indicates the document base to work on.
The - field (as a String).
The - value (as a String). Must be a valid regular expression. May be null or empty.
Throws:
SDXException

setUp

public void setUp(SearchLocations sLocs,
                  java.lang.String field,
                  java.lang.String value,
                  org.apache.lucene.search.regex.RegexCapabilities regexCapabilities)
           throws SDXException
Builds a list of terms from a field, optionally filtered by a regular expression.

Parameters:
The - SearchLocations that indicates the document base to work on.
The - field (as a String).
The - value (as a String). Must be a valid regular expression. May be null or empty.
The - RegexCapabilities to use with the RegexTermEnum.
Throws:
SDXException

getRegexTerms

public java.util.TreeMap getRegexTerms(java.util.BitSet docs)
                                throws SDXException
Builds a list of terms (as a TreeMap).

Parameters:
docs - The subset of documents (as a BitSet).
Returns:
The list of terms as a TreeMap.
Throws:
SDXException


Copyright © 2000-2010 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.