Ignore:
Timestamp:
2008-08-21T15:13:41+12:00 (16 years ago)
Author:
mdewsnip
Message:

Changed the Lucene code to use the Greenstone document OIDs directly, instead of creating its own numeric IDs and then mapping them to the Greenstone OIDs in the GDBM file. As well as being simpler and more space and speed efficient (the mapping no longer needs to be stored in the GDBM file, and no lookup needs to be done for each search result), this is another important step along the road to true incremental building.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/runtime-src/src/colservr/lucenequeryfilter.cpp

    r16915 r16947  
    163163
    164164  // assemble document results
    165   if (need_matching_docs (request.filterResultOptions)) {
    166    
     165  if (need_matching_docs (request.filterResultOptions))
     166  {
     167    // Loop through the query results (ordered by ranking)
    167168    int resultnum = 1;
    168     ResultDocInfo_t resultdoc;
    169     text_t trans_OID;
    170     vector<text_t>::iterator docorder_here = queryresults.docs.docorder.begin();
    171     vector<text_t>::iterator docorder_end = queryresults.docs.docorder.end();
    172 
    173     // Now handled by Lucene directly
    174     //if (endresults == -1) endresults = MAXNUMDOCS;
    175 
    176     while (docorder_here != docorder_end)
     169    vector<text_t>::iterator docorder_iterator = queryresults.docs.docorder.begin();
     170    while (docorder_iterator != queryresults.docs.docorder.end())
     171    {
     172      text_t doc_OID = (*docorder_iterator);
     173      // logout << "Matching doc OID: " << doc_OID << endl;
     174
     175      // Make sure this result is in the docset, and either in the request set or the request set is empty
     176      docresultmap::iterator doc_result = queryresults.docs.docset.find (doc_OID);
     177      if (doc_result != queryresults.docs.docset.end() && (request.docSet.empty() || in_set(request.docSet, doc_OID)))
    177178      {
    178         // Now handled by Lucene directly
    179         //if (resultnum > endresults) break;
    180      
    181         // translate the document number
    182         if (!translate(db_ptr, *docorder_here, trans_OID))
    183           {
    184             logout << text_t2ascii
    185                    << "warning: could not translate lucene document number \""
    186                    << *docorder_here << "\" to OID.\n\n";
    187            
    188           }
    189         else
    190           {
    191             docresultmap::iterator docset_here = queryresults.docs.docset.find (*docorder_here);
    192 
    193             // see if there is a result for this number,
    194             // if it is in the request set (or the request set is empty)
    195             if (docset_here != queryresults.docs.docset.end() && (request.docSet.empty() || in_set(request.docSet, trans_OID)))
    196               {
    197                 // Now handled by Lucene directly
    198                 //if (resultnum >= startresults) {
    199 
    200                 // add this document
    201                 resultdoc.OID = trans_OID;
    202                 resultdoc.result_num = resultnum;
    203                 resultdoc.ranking = (int)((*docset_here).second.docweight * 10000.0 + 0.5);
    204                 resultdoc.num_terms_matched = (*docset_here).second.num_query_terms_matched;
    205                
    206                 response.docInfo.push_back (resultdoc);
    207                 //}
    208                 ++resultnum;
    209               }
    210           } // else
    211        
    212         ++docorder_here;
    213       }
    214   } // if need matching docs
     179    // Add the matching document
     180    ResultDocInfo_t resultdoc;
     181    resultdoc.OID = doc_OID;
     182    resultdoc.result_num = resultnum;
     183    resultdoc.ranking = (int)((*doc_result).second.docweight * 10000.0 + 0.5);
     184    resultdoc.num_terms_matched = (*doc_result).second.num_query_terms_matched;
     185    response.docInfo.push_back (resultdoc);
     186
     187    resultnum++;
     188      }
     189
     190      docorder_iterator++;
     191    }
     192  }
    215193 
    216194  // assemble the term results
Note: See TracChangeset for help on using the changeset viewer.