Changeset 20910

Show
Ignore:
Timestamp:
05.11.2009 14:49:12 (10 years ago)
Author:
mdewsnip
Message:

Added a null pointer check to prevent rare errors when there are no terms in a search (it is entirely a filter).

Files:
1 modified

Legend:

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

    r18615 r20910  
    204204            int lucene_doc_num = hits.id(i - 1); 
    205205            Document doc = hits.doc(i - 1); 
    206             int doc_term_freq = ((Integer) doc_term_freq_map.get(new Integer(lucene_doc_num))).intValue(); 
     206            int doc_term_freq = 0; 
     207            Integer doc_term_freq_object = (Integer) doc_term_freq_map.get(new Integer(lucene_doc_num)); 
     208            if (doc_term_freq_object != null) 
     209            { 
     210            doc_term_freq = doc_term_freq_object.intValue(); 
     211            } 
    207212            lucene_query_result.addDoc(doc.get("docOID").trim(), hits.score(i-1), doc_term_freq); 
    208213        } 
     
    222227            int lucene_doc_num = hits.scoreDocs[i - 1].doc; 
    223228            Document doc = reader.document(lucene_doc_num); 
    224             int doc_term_freq = ((Integer) doc_term_freq_map.get(new Integer(lucene_doc_num))).intValue(); 
     229            int doc_term_freq = 0; 
     230            Integer doc_term_freq_object = (Integer) doc_term_freq_map.get(new Integer(lucene_doc_num)); 
     231            if (doc_term_freq_object != null) 
     232            { 
     233            doc_term_freq = doc_term_freq_object.intValue(); 
     234            } 
    225235            lucene_query_result.addDoc(doc.get("docOID").trim(), hits.scoreDocs[i-1].score, doc_term_freq); 
    226236        }