com.jalios.jcms.policy
Class BasicLuceneSearchEnginePolicyFilter

java.lang.Object
  extended by com.jalios.jcms.policy.AbstractPolicyFilter
      extended by com.jalios.jcms.policy.BasicLuceneSearchEnginePolicyFilter
All Implemented Interfaces:
PluginComponent, LuceneSearchEnginePolicyFilter, PolicyFilter, Comparable

public class BasicLuceneSearchEnginePolicyFilter
extends AbstractPolicyFilter
implements LuceneSearchEnginePolicyFilter, PluginComponent

This class allow developers to put hooks to change lucene search engine mechanism behaviour. To get more information about the current request in hooks, the method Channel#getCurrentJcmsContext() must be called.

Since:
jcms-5.7.0
Version:
$Revision: 22086 $
Author:
Jean-Philippe Encausse

Field Summary
static String REVISION
           
 
Fields inherited from class com.jalios.jcms.policy.AbstractPolicyFilter
order
 
Constructor Summary
BasicLuceneSearchEnginePolicyFilter()
           
 
Method Summary
 void filterCategoryDocument(org.apache.lucene.document.Document doc, Category cat, String lang)
          This method is called when the given Category is being index in the given language, just before writing the Document into the index.
 void filterFileDocument(org.apache.lucene.document.Document doc, File file)
          This method is called when the given File is being index, just before writing the Document into the index.
 void filterPublicationDocument(org.apache.lucene.document.Document doc, Publication pub, String lang)
          This method is called when the given Publication is being index in the given language, just before writing the Document into the index.
 org.apache.lucene.analysis.Analyzer getAnalyzer(String lang, boolean isIndexing, org.apache.lucene.analysis.Analyzer analyser)
          Return the Lucene Analyzer to use for a given language.
 float getCategoryBoost(Category cat, String lang, float jcms)
          Return the boost that should be apply to the lucene Document that will be created for the given Category.
 float getFieldBoost(Category cat, String lang, String fieldName, String fieldValue, float jcms)
          Return the boost that should be apply to the lucene Field that will be created for the given Category's field.
 float getFieldBoost(Publication pub, String lang, String fieldName, String fieldValue, float jcms)
          Return the boost that should be apply to the lucene Field that will be created for the given Publication's field.
 String[] getLanguageStopWords(String lang, String[] jcms)
           
 HashSet<String> getLanguageStopWordsSet(String lang, HashSet<String> jcms)
           
 float getPublicationBoost(Publication pub, String lang, float jcms)
          Return the boost that should be apply to the lucene Document that will be created for the given Publication.
 boolean init(Plugin plugin)
          Initialize the component with the given plugin configuration
 
Methods inherited from class com.jalios.jcms.policy.AbstractPolicyFilter
compareTo, equals, getOrder, setOrder
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values
Constructor Detail

BasicLuceneSearchEnginePolicyFilter

public BasicLuceneSearchEnginePolicyFilter()
Method Detail

init

public boolean init(Plugin plugin)
Description copied from interface: PluginComponent
Initialize the component with the given plugin configuration

Specified by:
init in interface PluginComponent
Parameters:
plugin - the calling plugin
Returns:
true if the component has been correctly initialized.
Since:
jcms-5.7.1
See Also:
PluginComponent.init(Plugin)

getLanguageStopWords

public String[] getLanguageStopWords(String lang,
                                     String[] jcms)
Specified by:
getLanguageStopWords in interface LuceneSearchEnginePolicyFilter

getLanguageStopWordsSet

public HashSet<String> getLanguageStopWordsSet(String lang,
                                               HashSet<String> jcms)
Specified by:
getLanguageStopWordsSet in interface LuceneSearchEnginePolicyFilter

getAnalyzer

public org.apache.lucene.analysis.Analyzer getAnalyzer(String lang,
                                                       boolean isIndexing,
                                                       org.apache.lucene.analysis.Analyzer analyser)
Description copied from interface: LuceneSearchEnginePolicyFilter
Return the Lucene Analyzer to use for a given language.

Specified by:
getAnalyzer in interface LuceneSearchEnginePolicyFilter
Parameters:
lang - the ISO-639 code of the language analyzed
isIndexing - true if the returned anallyzer is to be used for indexing, false in any other case (e.g. during search etc..) You may want to use this parameter to change the behaviour of your analyzer during those case (for example, synonym analyzer must generate synonyms only when indexing, not during search).
analyser - the internal Analyzer, created by JCMS, that should be returned if you do not want to return a customize analyzer
Returns:
a new Analyzer
See Also:
LuceneSearchEnginePolicyFilter.getAnalyzer(String, boolean, Analyzer)

getPublicationBoost

public float getPublicationBoost(Publication pub,
                                 String lang,
                                 float jcms)
Description copied from interface: LuceneSearchEnginePolicyFilter
Return the boost that should be apply to the lucene Document that will be created for the given Publication.
Default implementation alway return 1.0f.

A Document boost factor implicitly sets the starting boost of all fields to the specified value, Field-specific boosts are multiplied by the starting value, giving the final value of the field boost factor.

Specified by:
getPublicationBoost in interface LuceneSearchEnginePolicyFilter
Parameters:
pub - the Publication indexed
lang - the indexed language
jcms - the jcms internal boost
Returns:
a lucene boost value for the specified publication
See Also:
LuceneSearchEnginePolicyFilter.getPublicationBoost(Publication, String, float)

getFieldBoost

public float getFieldBoost(Publication pub,
                           String lang,
                           String fieldName,
                           String fieldValue,
                           float jcms)
Description copied from interface: LuceneSearchEnginePolicyFilter
Return the boost that should be apply to the lucene Field that will be created for the given Publication's field.
Default implementation:
  • TITLE_FIELD: 1.2f
  • ABSTRACT_FIELD: 1.1f
  • default: 1.0f
  • Note: Due to lucene default behavior, terms of shorter field (e.g. title) are naturally given more weight than terms in the document.
    Note: for Publication's field of type array (int[], long[], String[], etc) this method will only be called once. As we are creating appendable lucene Field in those case, calling the boost only for the first creationg prevent boost to multiplied as many times as there elements in the array.

    Specified by:
    getFieldBoost in interface LuceneSearchEnginePolicyFilter
    Parameters:
    pub - the publication indexed
    lang - the indexed language
    fieldName - the indexed field's name
    fieldValue - the String value of the indexed field)
    jcms - the jcms internal boost
    Returns:
    a float noting the boost value of the field
    See Also:
    LuceneSearchEnginePolicyFilter.getFieldBoost(Publication, String, String, String, float)

    getCategoryBoost

    public float getCategoryBoost(Category cat,
                                  String lang,
                                  float jcms)
    Description copied from interface: LuceneSearchEnginePolicyFilter
    Return the boost that should be apply to the lucene Document that will be created for the given Category.
    Default implementation alway return 1.0f.

    Specified by:
    getCategoryBoost in interface LuceneSearchEnginePolicyFilter
    Parameters:
    cat - the Category indexed
    lang - the indexed language
    jcms - the jcms internal boost
    Returns:
    a lucene boost value for the specified category
    See Also:
    LuceneSearchEnginePolicyFilter.getCategoryBoost(Category, String, float)

    getFieldBoost

    public float getFieldBoost(Category cat,
                               String lang,
                               String fieldName,
                               String fieldValue,
                               float jcms)
    Description copied from interface: LuceneSearchEnginePolicyFilter
    Return the boost that should be apply to the lucene Field that will be created for the given Category's field.
    Default implementation:
  • TITLE_FIELD: 1.2f
  • SYNONYMS_FIELD: 1.1f
  • default: 1.0f
  • Note: for Category's field of type array (int[], long[], String[], etc) this method will only be called once. As we are creating appendable lucene Field in those case, calling the boost only for the first creationg prevent boost to multiplied as many times as there elements in the array (Synonyms being a good examples).

    Specified by:
    getFieldBoost in interface LuceneSearchEnginePolicyFilter
    Parameters:
    cat - the Category indexed
    lang - the indexed language
    fieldName - the indexed field's name
    fieldValue - the String value of the indexed field)
    jcms - the jcms internal boost
    Returns:
    a float noting the boost value of the field
    See Also:
    LuceneSearchEnginePolicyFilter.getFieldBoost(Category, String, String, String, float)

    filterPublicationDocument

    public void filterPublicationDocument(org.apache.lucene.document.Document doc,
                                          Publication pub,
                                          String lang)
    Description copied from interface: LuceneSearchEnginePolicyFilter
    This method is called when the given Publication is being index in the given language, just before writing the Document into the index. You can use this hook to modify the Document as you wish by adding or removing field.

    Specified by:
    filterPublicationDocument in interface LuceneSearchEnginePolicyFilter
    Parameters:
    doc - the lucene Document that was created by JCMS search engine
    pub - the Publication being indexed
    lang - the indexed language
    See Also:
    LuceneSearchEnginePolicyFilter.filterPublicationDocument(Document, Publication, String)

    filterCategoryDocument

    public void filterCategoryDocument(org.apache.lucene.document.Document doc,
                                       Category cat,
                                       String lang)
    Description copied from interface: LuceneSearchEnginePolicyFilter
    This method is called when the given Category is being index in the given language, just before writing the Document into the index. You can use this hook to modify the Document as you wish by adding or removing field.

    Specified by:
    filterCategoryDocument in interface LuceneSearchEnginePolicyFilter
    Parameters:
    doc - the lucene Document that was created by JCMS search engine
    cat - the Category being indexed
    lang - the indexed language
    See Also:
    LuceneSearchEnginePolicyFilter.filterCategoryDocument(Document, Category, String)

    filterFileDocument

    public void filterFileDocument(org.apache.lucene.document.Document doc,
                                   File file)
    Description copied from interface: LuceneSearchEnginePolicyFilter
    This method is called when the given File is being index, just before writing the Document into the index. You can use this hook to modify the Document as you wish by adding or removing field.

    Specified by:
    filterFileDocument in interface LuceneSearchEnginePolicyFilter
    Parameters:
    doc - the lucene Document that was created by JCMS search engine
    file - the File being indexed
    See Also:
    LuceneSearchEnginePolicyFilter.filterFileDocument(Document, java.io.File)


    Copyright © 2001-2007 Jalios SA. All Rights Reserved.