Changeset 28163 for gs3-extensions

Show
Ignore:
Timestamp:
27.08.2013 12:59:37 (6 years ago)
Author:
kjdon
Message:

set a default sort field, and make sure it is not being set to null

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/util/SolrQueryWrapper.java

    r28125 r28163  
    5555    protected int max_docs = 100; 
    5656    protected String sort_order = SORT_DESCENDING; 
     57  protected String sort_field = SORT_BY_RANK; // don't want null default for solr 
    5758    protected ArrayList<String> _facets = new ArrayList<String>(); 
    5859    protected ArrayList<String> _facetQueries = new ArrayList<String>(); 
     
    7475        this.solr_core = solr_core; 
    7576    } 
    76    
     77  // make sure its not null. 
     78  public void setSortField(String sort_field) { 
     79    if (sort_field != null) { 
     80      this.sort_field = sort_field; 
     81    } 
     82  } 
     83 
    7784  public void setSortOrder(String order) 
    7885  { 
     
    201208        solrParams.set("q", query_string); 
    202209        // sort param, like "score desc" or "byORG asc" 
    203  
    204         if (this.sort_field != null) { 
    205             solrParams.set("sort", this.sort_field+" "+this.sort_order); 
    206         } 
    207  
     210        solrParams.set("sort", this.sort_field+" "+this.sort_order); 
    208211        // which result to start from 
    209212        solrParams.set("start", start_results);