TEXT   64
index ind
Guest on 11th March 2023 12:50:53 PM


  1. Index *ind;  
  2.  
  3. ind = IndexManager::openIndex("index-toc-file.bsc");  
  4.  // open the index specified by the table-of-content (toc) file "index-toc-file.bsc"
  5. // IndexManager recognizes the suffix of the toc file (in this case ".bsc") and uses it to
  6. // infer the actual type of the index to be opened (in this case, the basic index).
  7.  
  8. int t1;
  9. ...
  10. // now fetch the doc info list for term t1
  11. DocInfoList *dList = ind->docInfoList(t1);
  12.  
  13. dList->startIteration();
  14. while (dList->hasMore()) {
  15.   DocInfo * entry = dList->nextEntry(); // obtains a pointer to a static instance
  16.   cout << "entry doc id: " << entry->docID() << endl;
  17.   cout << "entry term count: " << entry->termCount() << endl;
  18.   // note that you MUST NOT delete entry!
  19. }
  20.  
  21. delete dList; // you MUST delete dList!
  22.  
  23. // TermInfoList can be accessed in exactly the same way
  24.  
  25. delete ind; // The IndexManager creates a dynamic instance.

Raw Paste

Login or Register to edit or fork this paste. It's free.