Diffrence between db.FTSearch and db.Search

ad_kumar used Ask the Experts™

I need to develop a scheduled search agent, which will search for the documents, based on a saved search criteria document and send number of results in a mail. Means agent will:
1. First pick the document in which search criteria (field specific) is stored
2. Create search query from saved search criteria
3. Get collection of the documents returned by search
4. Finaly send the number of documents returned by search (collection.count) in a mail to me

I need to know which method out of db.FTsearch and db.Search, will be most suitable for the scenario. My database is indexed.

What are the basic diffrences between two, why Lotus given two search metods, what are limitations of two (e.g. in terms of max number of documents returned, I may get more then 5000 docs in search result, and any other), and what are adwantages of one over other.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
db.search is based on a formula like
Form="myForm":"otherForm" & Status="Processed"
Just like a SELECT formula in a view
This could slow down processing since a temporary index (like view index) needs to be created.

A good alternative would be to use that search in a view and perform a notesview.getalldocumentsbykey: you'd only have to create the index once!

db.ftsearch looks like the search, but uses the full text index. Depending on the FTindex, you may find documents on their content in rich-text fields or attachments! That can be an advantage; but might just as well turn against you if you want to exclude documents of a with a certain type or status.
You need to have a FT-index prepared, or it won't work (unlike those view indexed, that get build on demand).

Both return a document collection. I don't think there's a limit like 5000 (unlike FTsearch in a view!)


Thanks CRAK for your response. I can't use getdocumentbykey, as I have a complax search criteria like "FORM=form1" AND "FIELd status CONTAINS 1" AND "FIELD B Doesn't contain 2" AND so on.

I need to choose either db.search or db.ftsearch.

I wanted to know comparison between to, advantages, disadvantages, and limitations etc.

    db.search can return all the documents, but in a very large database can take time to return.  If you're only doing it once, fine.  If its in a loop and you're doing it a lot or if users are waiting for the output, it will be slow.  I have a db that can take over 4 minutes to return results.

   db.ftsearch uses different syntax (its published in the knowledge base) but will be very fast -- nearly instant.  It will fail, however, if there are more than 5000 matching docs.  Also, it can be "behind" in terms of indexing for both documents that have been changed or deleted or new documents that have been added.

  I have one tool that is speed critical and does several hundred searches.  I use db.ftsearch with a max return of 5000 documents set so I get no errors.  99% of the time that's fine.  In any result set I get 5000 back, I drop that result and do a regular db.search and parse those instead.
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

ad kumar,
It looks as if you did that search in the (RT) search bar.... For a view formula that's not a complex thing though!

If all of those search parameters are fixed, as shown, those CAN be used to create a view with. In your example:
SELECT FORM="form1" & status="1" & !B="2" & .....

You'd be able to reuse the index here. If today you want to search for status="1", but tomorrow for status="2", this is probably not an option.

By the way: the !B="2" may look funny here. Is nearly the same as B!="2", unless B a multi value field. Just some background info.....

Taking a single value for B, e.g. "1", B!="2" would return TRUE, and !B="2" would return TRUE (!false) as well.
If B="2"... B!="2" returns FALSE and !B="2" returns (!true) FALSE.

If B has multiple values, e.g. "1":"2":"3", then B="2" would theoretically return false:true:false, resulting in "true". Added "!" means: !(true) = FALSE (not showing)
B!="2" would theoretically return true:false:true, resulting in TRUE (showing)!

In code: put this in a button and see!


@Text( A!="2" ) :
@Text( !(A="2") ) :
@Text( B!="2" ) :
@Text( !(B="2") ) :
@Text( C!="2" ) :
@Text( !(C="2") );

@prompt([ok]; "test"; @Implode(result; "-"));


Thanks a lot Andrew.
Mark my words Andrew.... your heading for a top 15 entry!
LOL.   I've got something like 3500 expert points in about 10 days of answering questions, so at this pace I should.  But I haven't yet found the right balance, so I'll probably slack off a bit.  I'll give the keys to the solution, but I won't write people's apps for them.
Just like me huh ?

I never wrote entire apps for people here!

Do you know some about refreshing/saving Excel OLE objects in lots of notes documents without having to answer "YES, please refresh this object for me" for every single document?
I've got an old question open that could help you raize a fair amount of points!?
not my thing, but I could probably talk to people.
Me too...
Sure! For $1500/day?!
I will do anything if i get paid that kinda amount !  I can be a slave and the master is allowed to beat the **** out of me.
Ah, Arun.

I see you've met my client base!
Let's find a sponsor for $3000! I'd do the beating for the other $1500!
Just kidding bro!
Guess its time to bring our Sno-Bro here. Its getting more interesting.
Does he have the $3000 to spend?
May be! You never know whats in his truck !

Ah, thanks for bringing me in.  I hope ad_kumar can handle our chit-chat... Arun, what do you mean you will do anything for that amount?  You will do anything for $1 or a couple of EE points.  HA HA
Cheers bro!
a shame, Arun, I don't know you well enough to really take advantage of an offer like that.  ;-)
So Sno... what do you say?
For $3000 you get to watch me spanking Arun?
uh Oh... Is Drew Gay ?
CRAK come on... Sno will come out with wierdest of his imaginations now !!!
LOL,  Arun -- "Drew" is a father of 3 girls.  While I suppose that doesn't preclude being gay, it definately is a sign to the negative.

What's wrong with Sno picturing us making an honest living? Perhaps if he likes the thought he's willing to offer a bonus, or "hire" us again!?
Yea there is a little bit of sign for you drew.

Sno is thinking....


Hi Andrew,

One thing, when db.search get fail on returning 5000 documents, how we detect it in script, means what it returns (any specific error or what).

I am married also Drew, this is just some fun Arun likes to joke about occasionally... now CRAK if I get paid to beat Arun it's one thing, but I would not pay to do this since he will probably allow it for free.

What I do is set the max to 5000, then check to see if it returned 5000.  I realize it is statistically possible to have an exactly 5000 result in which case I'd be 'wrong' to re-do the search using the slower method, but I'm just a wild and crazy kinda a guy that way.

If you don't specify a max, by using a 0, than if the result is more than 5000 lotuscript throws and error and you're required to trap it with an "On Error" statement -- which I believe to be poor code practice.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial