Changeset 16443

Show
Ignore:
Timestamp:
17.07.2008 16:20:14 (12 years ago)
Author:
mdewsnip
Message:

Changed the "id" attributes of "<Match>" tags returned so they don't necessarily have to be integers, in preparation for changing to return Greenstone docOIDs instead of the Lucene nodeIDs (for efficiency and to allow incremental building).

Location:
indexers/trunk/lucene-gs/src/org/greenstone/LuceneWrapper
Files:
2 modified

Legend:

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

    r16015 r16443  
    187187        for (int i = start_results; i <= hits.length(); i++) { 
    188188            Document doc = hits.doc(i - 1); 
    189             lucene_query_result.addDoc(Long.parseLong(doc.get("nodeID").trim()), hits.score(i-1)); 
     189            lucene_query_result.addDoc(doc.get("nodeID").trim(), hits.score(i-1)); 
    190190        } 
    191191        } 
     
    203203        for (int i = start_results; (i <= hits.scoreDocs.length && i <= end_results); i++) { 
    204204            Document doc = reader.document(hits.scoreDocs[i - 1].doc); 
    205             lucene_query_result.addDoc(Long.parseLong(doc.get("nodeID").trim()), hits.scoreDocs[i-1].score); 
     205            lucene_query_result.addDoc(doc.get("nodeID").trim(), hits.scoreDocs[i-1].score); 
    206206        } 
    207207        } 
  • indexers/trunk/lucene-gs/src/org/greenstone/LuceneWrapper/LuceneQueryResult.java

    r13686 r16443  
    110110    } 
    111111 
    112     public void addDoc(long doc, float rank) { 
    113     DocInfo doc_info = new DocInfo(doc, rank); 
    114     docs_.add(doc_info); 
     112    public void addDoc(String id, float rank) 
     113    { 
     114    docs_.add(new DocInfo(id, rank)); 
    115115    } 
    116116     
     
    220220    } 
    221221 
    222     public class DocInfo { 
    223      
    224     public long num_=0; 
    225     public float rank_=0; 
    226      
    227     public DocInfo(long doc, float rank) { 
    228         num_=doc; 
    229         rank_=rank; 
    230     } 
    231     public String toString(){ 
    232         return ""+num_+"("+rank_+")"; 
    233     } 
    234     public String toXMLString() { 
    235         return "<Match id=\"" + num_ + "\" rank=\"" + rank_ +"\" />"; 
    236     } 
    237     } 
     222 
     223    public class DocInfo 
     224    { 
     225    public String id_ = ""; 
     226    public float rank_ = 0; 
     227 
     228    public DocInfo (String id, float rank) 
     229    { 
     230        id_ = id; 
     231        rank_ = rank; 
     232    } 
     233 
     234    public String toString() 
     235    { 
     236        return "" + id_ + " (" + rank_ + ")"; 
     237    } 
     238 
     239    public String toXMLString() 
     240    { 
     241        return "<Match id=\"" + id_ + "\" rank=\"" + rank_ + "\" />"; 
     242    } 
     243    } 
     244 
    238245 
    239246    // where should this go??? 
    240      
    241247    public static String xmlSafe(String text) { 
    242248    text = text.replaceAll("&","&amp;amp;");