Changeset 27086

Show
Ignore:
Timestamp:
14.03.2013 13:03:30 (7 years ago)
Author:
kjdon
Message:

added reverse sort option to lucene sorting of search results

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/common-src/indexers/lucene-gs/src/org/greenstone/LuceneWrapper3/GS2LuceneQuery.java

    r26157 r27086  
    6161    protected String full_indexdir=""; 
    6262 
     63  protected boolean reverse_sort = false; 
    6364    protected Sort sorter=new Sort(); 
    6465    protected Filter filter = null; 
     
    118119        this.sorter = new Sort(); 
    119120    } else { 
    120         this.sorter = new Sort(new SortField(sort_field,SortField.STRING)); // **** can do better than this?!? 
    121     } 
    122     } 
     121      this.sorter = new Sort(new SortField(sort_field,SortField.STRING, this.reverse_sort)); // **** can do better than this?!? 
     122    } 
     123    } 
     124  public void setReverseSort() { 
     125    this.reverse_sort = true; 
     126    if (this.sort_field != null) { 
     127      this.sorter = new Sort(new SortField(this.sort_field, SortField.STRING, this.reverse_sort)); 
     128    } 
     129  } 
     130  public boolean getReverseSort() { 
     131    return this.reverse_sort; 
     132  } 
    123133 
    124134    public void setFilterString(String filter_string) { 
     
    485495    { 
    486496    if (args.length == 0) { 
    487         System.out.println("Usage: GS2LuceneQuery <index directory> [-fuzziness value] [-filter filter_string] [-sort sort_field] [-dco AND|OR] [-startresults number -endresults number] [query]"); 
     497        System.out.println("Usage: GS2LuceneQuery <index directory> [-fuzziness value] [-filter filter_string] [-sort sort_field] [-reverse_sort][-dco AND|OR] [-startresults number -endresults number] [query]"); 
    488498        return; 
    489499    } 
     
    516526            i++; 
    517527            queryer.setSortField(args[i]); 
     528        } 
     529        else if (args[i].equals("-reverse_sort")) { 
     530          queryer.setReverseSort(); 
    518531        } 
    519532        else if (args[i].equals("-filter")) { 
     
    592605        String sort_string = queryer.getSortField(); 
    593606        query_result_cache_file_name += ((sort_string != null) ? sort_string : "") + "-"; 
     607        String reverse_sort_string = (queryer.getReverseSort() ? "1" : "0"); 
     608        query_result_cache_file_name += reverse_sort_string + "-"; 
    594609        String default_conjunction_operator = queryer.getDefaultConjunctionOperator(); 
    595610        query_result_cache_file_name += default_conjunction_operator + "-";