Changeset 30159


Ignore:
Timestamp:
09/02/15 11:30:32 (5 years ago)
Author:
kjdon
Message:

making all search results indexes start from 0 not 1.

Location:
main/trunk/greenstone2/common-src/indexers/lucene-gs/src/org/greenstone/LuceneWrapper4
Files:
2 edited

Legend:

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

    r29167 r30159  
    330330        // Output the matching documents
    331331        lucene_query_result.setStartResults(start_results);
    332         lucene_query_result.setEndResults(hits.totalHits);
    333 
    334         for (int i = start_results; i <= hits.totalHits; i++) {
    335             int lucene_doc_num = hits.scoreDocs[i - 1].doc;
     332        lucene_query_result.setEndResults(hits.totalHits); // ??
     333
     334        for (int i = start_results; i < hits.totalHits; i++) {
     335          int lucene_doc_num = hits.scoreDocs[i ].doc; // i-1
    336336            Document doc = reader.document(lucene_doc_num);
    337337            int doc_term_freq = 0;
     
    341341            doc_term_freq = doc_term_freq_object.intValue();
    342342            }
    343             lucene_query_result.addDoc(doc.get("docOID").trim(), hits.scoreDocs[i-1].score, doc_term_freq);
     343            lucene_query_result.addDoc(doc.get("docOID").trim(), hits.scoreDocs[i].score, doc_term_freq);
    344344        }
    345345        }
     
    356356
    357357        // Output the matching documents
    358         for (int i = start_results; (i <= hits.scoreDocs.length && i <= end_results); i++) {
    359             int lucene_doc_num = hits.scoreDocs[i - 1].doc;
     358        for (int i = start_results; (i < hits.scoreDocs.length && i < end_results); i++) {
     359            int lucene_doc_num = hits.scoreDocs[i].doc;
    360360            Document doc = reader.document(lucene_doc_num);
    361361            int doc_term_freq = 0;
     
    365365            doc_term_freq = doc_term_freq_object.intValue();
    366366            }
    367             lucene_query_result.addDoc(doc.get("docOID").trim(), hits.scoreDocs[i-1].score, doc_term_freq);
     367            lucene_query_result.addDoc(doc.get("docOID").trim(), hits.scoreDocs[i].score, doc_term_freq);
    368368        }
    369369        }
  • main/trunk/greenstone2/common-src/indexers/lucene-gs/src/org/greenstone/LuceneWrapper4/SharedSoleneQuery.java

    r29148 r30159  
    4141    protected String sort_field = null;
    4242    protected String filter_string = null;
    43     protected int start_results=1;
     43    protected int start_results=0;
    4444    protected int end_results=Integer.MAX_VALUE;
    4545
     
    107107       
    108108    public void setStartResults(int start_results) {
    109     if (start_results < 1) {
    110         start_results = 1;
     109    if (start_results < 0) {
     110        start_results = 0;
    111111    }
    112112    this.start_results = start_results;
Note: See TracChangeset for help on using the changeset viewer.