Changeset 29544


Ignore:
Timestamp:
2014-12-08T11:23:09+13:00 (7 years ago)
Author:
kjdon
Message:

sort order param is now reversesort, and moved here instead of in sharedsolene..

File:
1 edited

Legend:

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

    r29428 r29544  
    4141public class GS2LuceneSearch extends SharedSoleneGS2FieldSearch
    4242{
     43  protected static final String SORT_ORDER_PARAM = "reverseSort";
     44  protected static final String SORT_ORDER_REVERSE = "1";
     45  protected static final String SORT_ORDER_NORMAL = "0";
     46
    4347    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.GS2LuceneSearch.class.getName());
    4448
     
    4751    public GS2LuceneSearch()
    4852    {
     53        paramDefaults.put(SORT_ORDER_PARAM, SORT_ORDER_NORMAL);
    4954        this.lucene_src = new GS2LuceneQuery();
    5055    }
     
    5661    }
    5762
     63    /** add in the Lucene specific params to TextQuery */
     64    protected void addCustomQueryParams(Element param_list, String lang)
     65    {
     66        super.addCustomQueryParams(param_list, lang);
     67        /** Add in the reverse sort on/off param */
     68        createParameter(SORT_ORDER_PARAM, param_list, lang);
     69    }
     70  /** add in Lucene specific params for AdvancedFieldQuery */
     71  protected void addCustomQueryParamsAdvField(Element param_list, String lang)
     72    {
     73        super.addCustomQueryParamsAdvField(param_list, lang);
     74        createParameter(SORT_ORDER_PARAM, param_list, lang);
     75       
     76    }
     77    /** create a param and add to the list */
     78  protected void createParameter(String name, Element param_list, String lang)
     79  {
     80    Document doc = param_list.getOwnerDocument();
     81    Element param = null;
     82    String param_default = paramDefaults.get(name);
     83    if (name.equals(SORT_ORDER_PARAM)) {
     84        String[] vals = { SORT_ORDER_REVERSE, SORT_ORDER_NORMAL };
     85        String[] vals_texts = { getTextString("param." + SORT_ORDER_PARAM + "." + SORT_ORDER_REVERSE, lang), getTextString("param." + SORT_ORDER_PARAM + "." + SORT_ORDER_NORMAL, lang) };
     86
     87        param = GSXML.createParameterDescription(doc, SORT_ORDER_PARAM, getTextString("param." + SORT_ORDER_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, param_default, vals, vals_texts);
     88    }
     89
     90    if (param != null)
     91      {
     92    param_list.appendChild(param);
     93      }
     94    else
     95      {
     96    super.createParameter(name, param_list, lang);
     97      }
     98   
     99  }
    58100    /** methods to handle actually doing the query */
    59101
     
    155197        }
    156198
    157         // default order for rank is descending, while for other
    158         // fields it is ascending. So reverse_sort is different for
    159         // the two cases.
    160         if (sort_field.equals(GS2LuceneQuery.SORT_RANK)) {
    161           if (sort_order.equals(SORT_ORDER_ASCENDING)) {
    162             this.lucene_src.setReverseSort(true);
    163           } else {
    164             this.lucene_src.setReverseSort(false);
    165           }
     199        if (sort_order.equals(SORT_ORDER_REVERSE)) {
     200          this.lucene_src.setReverseSort(true);
    166201        } else {
    167           if (sort_order.equals(SORT_ORDER_DESCENDING)) {
    168             this.lucene_src.setReverseSort(true);
    169           } else {
    170             this.lucene_src.setReverseSort(false);
    171           }
     202          this.lucene_src.setReverseSort(false);
    172203        }
    173204        this.lucene_src.setIndexDir(indexdir + index);
Note: See TracChangeset for help on using the changeset viewer.