wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

NotesDatabase.FTSearch vs NotesView.FTSearch


When looking for data in a Notes database using LotusScript you have 3 possibilities: NotesView.getDocumentByKey (and its cousing NotesView.getEntryByKey), NotesDatabase.dbSearch and [NotesView|NotesDatabase].FTSearch. Use each of them wisely (when to use what might make another nice post). I want to focus on FTSearch for now. One would expect that a fulltext search against a view is substantial faster than against a whole database. However the results are quite different. The fulltext index is build once for the entire database. So even a FTSearch against a view will use the Index for the whole database. Searches are actually very fast. What makes a difference is how the results are processed and how you intend to use the result. If you plan to list them all out, there is no real difference. If you only want to show a subset continue reading. Very often a search returns 1000 documents but you only want to show 20 or 50 at a time. The core search returns an document collection that contains the UNIDs but not the document objects. When you use db.FTSearch the document objects are initialised when you loop through the collection as do a NotesDocumentCollection.getNextDocument(doc). So if you only use a fraction (50 of 1000) you would only initialize document objects 50 times. On a NotesView.FTSearch on the other hand the collection gets fully initialised since Domino needs to check if the document meets the view's selection criteria. If it matches the document stays in the result collection, if not it gets removed. So even if you would only use a few documents you would need to bear the waiting time of all document object initialisation calls. Unfortunately if you need a very specific sorting sequence you need to stick with a view. Andre gives more advice. In summary: in cases where your expected results are much bigger than what you want to show NotesDatabase.FTSearch beats NotesView.FTSearch

Posted by on 22 July 2009 | Comments (1) | categories: Show-N-Tell Thursday

Comments

  1. posted by Nicolas Melay on Saturday 24 January 2015 AD:
    What about NotesViewEntryCollection.FTSearch ?
    Seems pretty pretty fast to me.
    Doing such an FTSearch on a 5000+ documents database, parsing the resulting 1500+ view entries takes less than 1 second here.

    (yeah, I known I'm commenting on a 5 years old post...)