Changeset 27085

Show
Ignore:
Timestamp:
14.03.2013 13:02:54 (7 years ago)
Author:
kjdon
Message:

added sortorder param to lucene searching

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2LuceneSearch.java

    r25885 r27085  
    3838public class GS2LuceneSearch extends SharedSoleneGS2FieldSearch 
    3939{ 
     40 
     41  protected static final String SORT_ORDER_PARAM = "sortOrder"; 
     42  protected static final String SORT_ORDER_DESCENDING = "1"; 
     43  protected static final String SORT_ORDER_ASCENDING = "0"; 
     44 
    4045    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.GS2LuceneSearch.class.getName()); 
    4146 
     
    5358    } 
    5459 
     60    /** add in the Lucene specific params to TextQuery */ 
     61    protected void addCustomQueryParams(Element param_list, String lang) 
     62    { 
     63        super.addCustomQueryParams(param_list, lang); 
     64        /** Lucene's/Solr's rank param is based on index fields, not ranked/not */ 
     65        createParameter(SORT_ORDER_PARAM, param_list, lang); 
     66    } 
     67   
     68  /** create a param and add to the list */ 
     69  protected void createParameter(String name, Element param_list, String lang) 
     70    { 
     71      Element param = null; 
     72      if (name.equals(SORT_ORDER_PARAM)) { 
     73        String[] vals = { SORT_ORDER_ASCENDING, SORT_ORDER_DESCENDING }; 
     74        String[] vals_texts = { getTextString("param." + SORT_ORDER_PARAM + "." + SORT_ORDER_ASCENDING, lang), getTextString("param." + SORT_ORDER_PARAM + "." + SORT_ORDER_DESCENDING, lang) }; 
     75 
     76        param = GSXML.createParameterDescription(this.doc, SORT_ORDER_PARAM, getTextString("param." + SORT_ORDER_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, SORT_ORDER_ASCENDING, vals, vals_texts); 
     77      } 
     78       
     79      if (param != null) 
     80        { 
     81          param_list.appendChild(param); 
     82        } 
     83      else 
     84        { 
     85          super.createParameter(name, param_list, lang); 
     86        } 
     87    } 
    5588    /** methods to handle actually doing the query */ 
    5689 
     
    107140                this.lucene_src.setSortField(value); 
    108141            } 
     142            else if (name.equals(SORT_ORDER_PARAM)) { 
     143                if (value.equals(SORT_ORDER_DESCENDING)) { 
     144                  this.lucene_src.setReverseSort(); 
     145                } 
     146              } 
    109147            else if (name.equals(LEVEL_PARAM)) 
    110148            {