Changeset 29542

Show
Ignore:
Timestamp:
08.12.2014 11:09:14 (4 years ago)
Author:
kjdon
Message:

lucene sort order param has changed to reverse sort on/off, but solr uses asc/desc. I have moved the sort order param out of sharedsolenegs2fieldsearch and into lucenesearch and solrsearch so they can have different versions of it. added code to handle creating the param, and a properties file for the text strings. build.xml modified to copy the properties file over.

Location:
gs3-extensions/solr/trunk/src
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • gs3-extensions/solr/trunk/src/build.xml

    r29152 r29542  
    8383    SolrQueryResult.java"/>             
    8484   
    85  <!-- <property name="property-files"  
    86     value=""/>  --> 
     85 <property name="property-files"  
     86    value="GS2SolrSearch.properties"/>   
    8787 
    8888             
     
    116116  <target name="copy-files" description="Helper-target: copy files across for add-service target"> 
    117117     
    118     <!-- May want this back if we add in Solr .properties files--> 
    119 <!--    <echo/> 
     118    <echo/> 
    120119    <echo>Adding to gsdl3 properties area: properties/${property-files}</echo> 
    121     <copy todir="${classesdir}"> 
     120    <copy todir="${web.classesdir}"> 
    122121          <filelist id="prop-files" dir="properties" files="${property-files}"/> 
    123122    </copy> 
    124 --> 
    125123    <echo/> 
    126124    <echo>Adding to gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars}</echo> 
     
    177175     
    178176 
    179 <!--     
     177 
    180178    <echo/> 
    181179    <echo>Removing from  gsdl3 properties area: properties/${property-files}</echo> 
    182180    <delete failonerror="false"> 
    183           <filelist dir="${classesdir}" files="${property-files}"/> 
     181          <filelist dir="${web.classesdir}" files="${property-files}"/> 
    184182    </delete> 
    185 --> 
     183 
    186184    <echo/> 
    187185    <echo>Removing from gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars} gs3-solr.jar</echo> 
  • gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/service/GS2SolrSearch.java

    r29355 r29542  
    4949public class GS2SolrSearch extends SharedSoleneGS2FieldSearch 
    5050{ 
     51 
     52  protected static final String SORT_ORDER_PARAM = "sortOrder"; 
     53  protected static final String SORT_ORDER_DESCENDING = "1"; 
     54  protected static final String SORT_ORDER_ASCENDING = "0"; 
     55 
    5156    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.GS2SolrSearch.class.getName()); 
    5257 
     
    6065    public GS2SolrSearch() 
    6166    { 
     67                paramDefaults.put(SORT_ORDER_PARAM, SORT_ORDER_DESCENDING); 
    6268        does_faceting = true; 
    6369        // Used to store the solr cores that match the required 'level'  
     
    243249    } 
    244250 
     251    /** add in the SOLR specific params to TextQuery */ 
     252    protected void addCustomQueryParams(Element param_list, String lang) 
     253    { 
     254        super.addCustomQueryParams(param_list, lang); 
     255        /** Add in the sort order asc/desc param */ 
     256        createParameter(SORT_ORDER_PARAM, param_list, lang); 
     257    } 
     258  /** add in SOLR specific params for AdvancedFieldQuery */ 
     259  protected void addCustomQueryParamsAdvField(Element param_list, String lang) 
     260    { 
     261        super.addCustomQueryParamsAdvField(param_list, lang); 
     262        createParameter(SORT_ORDER_PARAM, param_list, lang); 
     263         
     264    } 
     265    /** create a param and add to the list */ 
     266  protected void createParameter(String name, Element param_list, String lang) 
     267  { 
     268    Document doc = param_list.getOwnerDocument(); 
     269    Element param = null; 
     270    String param_default = paramDefaults.get(name); 
     271    if (name.equals(SORT_ORDER_PARAM)) { 
     272        String[] vals = { SORT_ORDER_ASCENDING, SORT_ORDER_DESCENDING };  
     273    String[] vals_texts = { getTextString("param." + SORT_ORDER_PARAM + "." + SORT_ORDER_ASCENDING, lang), getTextString("param." + SORT_ORDER_PARAM + "." + SORT_ORDER_DESCENDING, lang) };         
     274     
     275    param = GSXML.createParameterDescription(doc, SORT_ORDER_PARAM, getTextString("param." + SORT_ORDER_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, param_default, vals, vals_texts); 
     276    } 
     277 
     278    if (param != null) 
     279      { 
     280    param_list.appendChild(param); 
     281      } 
     282    else 
     283      { 
     284    super.createParameter(name, param_list, lang); 
     285      } 
     286     
     287  } 
     288   
    245289    /** methods to handle actually doing the query */ 
    246290