Changeset 12846 for trunk/indexers


Ignore:
Timestamp:
2006-09-26T10:09:48+12:00 (18 years ago)
Author:
mdewsnip
Message:

Minor changes.

File:
1 edited

Legend:

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

    r12776 r12846  
    2929import org.apache.lucene.search.IndexSearcher;
    3030import org.apache.lucene.search.Query;
    31 import org.apache.lucene.search.QueryFilter;
    3231import org.apache.lucene.search.RangeFilter;
    3332import org.apache.lucene.search.Searcher;
     
    3736public class GS2LuceneQuery
    3837{
     38    static private String TEXTFIELD = "TX";
     39
    3940    // Use the standard set of English stop words by default
    4041    static private String[] stop_words = StandardAnalyzer.STOP_WORDS;
     
    5354
    5455        // 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[] { }));
    5758
    5859        Sort sorter = new Sort();
     
    143144            while (iter.hasNext()) {
    144145            Term term = (Term) iter.next();
    145             // If you wanted to limit this to just TX terms add
     146            // If you wanted to limit this to just text terms add
    146147            // something like this:
    147             //if (term.field().equals("TX"))
     148            //if (term.field().equals(TEXTFIELD))
    148149            term_counts.put(term.text(), new Integer(0));
    149150            term_fields.put(term.text(), term.field());
     
    160161            Hit hit = (Hit) hit_iter.next();
    161162            Document doc = hit.getDocument();
    162             String node_id = doc.get("nodeID");
    163163           
    164164            // May not be paging results
    165165            if (start_results == 1 && end_results == -1) {
     166                String node_id = doc.get("nodeID");
    166167                System.out.println("  <Match id=\"" + node_id + "\" />");
    167168            }
    168169            // Otherwise skip up until page offset
    169170            else if (start_results <= counter && counter <= end_results) {
     171                String node_id = doc.get("nodeID");
    170172                System.out.println("  <Match id=\"" + node_id + "\" />");
    171173            }
     
    173175           
    174176            // From the document, extract the Term Vector for the
    175             // TX field
    176             TermFreqVector term_freq_vector = reader.getTermFreqVector(hit.getId(), "TX");
     177            // text field
     178            TermFreqVector term_freq_vector = reader.getTermFreqVector(hit.getId(), TEXTFIELD);
    177179            if (term_freq_vector != null && term_freq_vector.size() > 0) {
    178180                int[] term_frequencies = term_freq_vector.getTermFrequencies();
     
    311313        while (o < mutable_query_string.length()) {
    312314        char c = mutable_query_string.charAt(o);
    313         if (s == 0 && c == 'T') {
     315        if (s == 0 && c == TEXTFIELD.charAt(0)) {
    314316            ///ystem.err.println("Found T!");
    315317            s = 1;
    316318        }
    317319        else if (s == 1) {
    318             if (c == 'X') {
     320            if (c == TEXTFIELD.charAt(1)) {
    319321            ///ystem.err.println("Found X!");
    320322            s = 2;
Note: See TracChangeset for help on using the changeset viewer.