Changeset 28031
- Timestamp:
- 2013-08-13T13:33:08+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/common-src/indexers/lucene-gs/src/org/greenstone/LuceneWrapper3/GS2LuceneQuery.java
r27086 r28031 59 59 public class GS2LuceneQuery extends SharedSoleneQuery 60 60 { 61 public static String SORT_RANK = "rank"; 62 public static String SORT_NATURAL = "natural"; 63 61 64 protected String full_indexdir=""; 62 65 66 protected int sort_type = SortField.SCORE; 63 67 protected boolean reverse_sort = false; 64 68 protected Sort sorter=new Sort(); … … 98 102 Directory full_indexdir_dir = FSDirectory.open(new File(full_indexdir)); 99 103 searcher = new IndexSearcher(full_indexdir_dir,true); 104 // need to set this to get it to compute ranks when sorting by fields 105 ((IndexSearcher)searcher).setDefaultFieldSortScoring(true,true); 100 106 reader = ((IndexSearcher) searcher).getIndexReader(); 101 107 108 109 this.sorter = new Sort(new SortField(this.sort_field, this.sort_type, this.reverse_sort)); 102 110 } 103 111 catch (IOException exception) { … … 114 122 115 123 public void setSortField(String sort_field) { 116 super.setSortField(sort_field); 117 118 if (sort_field == null) {119 this.sorter = new Sort(); 120 } else {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 }124 if (sort_field.equals(SORT_RANK)) { 125 this.sort_field = null; 126 this.sort_type = SortField.SCORE; 127 } else if (sort_field.equals(SORT_NATURAL)) { 128 this.sort_field = null; 129 this.sort_type = SortField.DOC; 130 } else { 131 this.sort_field = sort_field; 132 this.sort_type = SortField.STRING; // for now. numeric?? 133 } 134 } 135 public void setReverseSort(boolean reverse) { 136 this.reverse_sort = reverse; 129 137 } 130 138 public boolean getReverseSort() { … … 528 536 } 529 537 else if (args[i].equals("-reverse_sort")) { 530 queryer.setReverseSort( );538 queryer.setReverseSort(true); 531 539 } 532 540 else if (args[i].equals("-filter")) {
Note:
See TracChangeset
for help on using the changeset viewer.