Changeset 27068

Show
Ignore:
Timestamp:
12.03.2013 14:59:41 (7 years ago)
Author:
kjdon
Message:

adding in reverse sort option

Files:
1 modified

Legend:

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

    r24731 r27068  
    6565    private String fuzziness = null; 
    6666    private String sort_field = null; 
     67  private boolean reverse_sort = false; 
    6768    private Sort sorter=new Sort(); 
    6869    private String filter_string = null; 
     
    132133    try {                
    133134        Query query_including_stop_words = query_parser_no_stop_words.parse(query_string); 
     135        System.err.println("stop query class="+query_including_stop_words.getClass().getName()); 
    134136        query_including_stop_words = query_including_stop_words.rewrite(reader); 
    135          
    136         // System.err.println("********* query_string " + query_string + "****"); 
     137        System.err.println("stop query class="+query_including_stop_words.getClass().getName());     
     138        System.err.println("********* query_string " + query_string + "****"); 
    137139 
    138140        Query query = parseQuery(reader, query_parser, query_string, fuzziness); 
     
    305307        this.sorter = new Sort(); 
    306308    } else { 
    307         this.sorter = new Sort(sort_field); 
     309      this.sorter = new Sort(sort_field, this.reverse_sort); 
    308310    } 
    309311    } 
     
    311313    return this.sort_field; 
    312314    } 
    313          
     315  public void setReverseSort() { 
     316    this.reverse_sort = true; 
     317    if (this.sort_field != null) { 
     318      this.sorter = new Sort(this.sort_field, this.reverse_sort); 
     319    } 
     320  } 
     321  public boolean getReverseSort() { 
     322    return this.reverse_sort; 
     323  } 
    314324    public void setStartResults(int start_results) { 
    315325    if (start_results < 1) { 
     
    475485 
    476486    if (args.length == 0) { 
    477         System.out.println("Usage: GS2LuceneQuery <index directory> [-fuzziness value] [-filter filter_string] [-sort sort_field] [-dco AND|OR] [-startresults number -endresults number] [query]"); 
     487        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]"); 
    478488        return; 
    479489    } 
     
    506516            i++; 
    507517            queryer.setSortField(args[i]); 
     518        } 
     519        else if (args[i].equals("-reverse_sort")) { 
     520          queryer.setReverseSort(); 
    508521        } 
    509522        else if (args[i].equals("-filter")) { 
     
    582595        String sort_string = queryer.getSortField(); 
    583596        query_result_cache_file_name += ((sort_string != null) ? sort_string : "") + "-"; 
     597        String reverse_sort_string = (queryer.getReverseSort() ? "1" : "0"); 
     598        query_result_cache_file_name += reverse_sort_string + "-"; 
    584599        String default_conjunction_operator = queryer.getDefaultConjunctionOperator(); 
    585600        query_result_cache_file_name += default_conjunction_operator + "-";