Changeset 12846 for trunk/indexers
- Timestamp:
- 2006-09-26T10:09:48+12:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/indexers/lucene-gs/src/org/greenstone/LuceneWrapper/GS2LuceneQuery.java
r12776 r12846 29 29 import org.apache.lucene.search.IndexSearcher; 30 30 import org.apache.lucene.search.Query; 31 import org.apache.lucene.search.QueryFilter;32 31 import org.apache.lucene.search.RangeFilter; 33 32 import org.apache.lucene.search.Searcher; … … 37 36 public class GS2LuceneQuery 38 37 { 38 static private String TEXTFIELD = "TX"; 39 39 40 // Use the standard set of English stop words by default 40 41 static private String[] stop_words = StandardAnalyzer.STOP_WORDS; … … 53 54 54 55 // Create one query parser with the standard set of stop words, and one with none 55 QueryParser query_parser = new QueryParser( "TX", new StandardAnalyzer(stop_words));56 QueryParser query_parser_no_stop_words = new QueryParser( "TX", new StandardAnalyzer(new String[] { }));56 QueryParser query_parser = new QueryParser(TEXTFIELD, new StandardAnalyzer(stop_words)); 57 QueryParser query_parser_no_stop_words = new QueryParser(TEXTFIELD, new StandardAnalyzer(new String[] { })); 57 58 58 59 Sort sorter = new Sort(); … … 143 144 while (iter.hasNext()) { 144 145 Term term = (Term) iter.next(); 145 // If you wanted to limit this to just TXterms add146 // If you wanted to limit this to just text terms add 146 147 // something like this: 147 //if (term.field().equals( "TX"))148 //if (term.field().equals(TEXTFIELD)) 148 149 term_counts.put(term.text(), new Integer(0)); 149 150 term_fields.put(term.text(), term.field()); … … 160 161 Hit hit = (Hit) hit_iter.next(); 161 162 Document doc = hit.getDocument(); 162 String node_id = doc.get("nodeID");163 163 164 164 // May not be paging results 165 165 if (start_results == 1 && end_results == -1) { 166 String node_id = doc.get("nodeID"); 166 167 System.out.println(" <Match id=\"" + node_id + "\" />"); 167 168 } 168 169 // Otherwise skip up until page offset 169 170 else if (start_results <= counter && counter <= end_results) { 171 String node_id = doc.get("nodeID"); 170 172 System.out.println(" <Match id=\"" + node_id + "\" />"); 171 173 } … … 173 175 174 176 // From the document, extract the Term Vector for the 175 // TXfield176 TermFreqVector term_freq_vector = reader.getTermFreqVector(hit.getId(), "TX");177 // text field 178 TermFreqVector term_freq_vector = reader.getTermFreqVector(hit.getId(), TEXTFIELD); 177 179 if (term_freq_vector != null && term_freq_vector.size() > 0) { 178 180 int[] term_frequencies = term_freq_vector.getTermFrequencies(); … … 311 313 while (o < mutable_query_string.length()) { 312 314 char c = mutable_query_string.charAt(o); 313 if (s == 0 && c == 'T') {315 if (s == 0 && c == TEXTFIELD.charAt(0)) { 314 316 ///ystem.err.println("Found T!"); 315 317 s = 1; 316 318 } 317 319 else if (s == 1) { 318 if (c == 'X') {320 if (c == TEXTFIELD.charAt(1)) { 319 321 ///ystem.err.println("Found X!"); 320 322 s = 2;
Note:
See TracChangeset
for help on using the changeset viewer.