Link to home
Start Free TrialLog in
Avatar of ad_kumar
ad_kumar

asked on

Diffrence between db.FTSearch and db.Search

Hi,

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.

Thanks.
Avatar of CRAK
CRAK
Flag of Netherlands image

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!)
Avatar of ad_kumar
ad_kumar

ASKER

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.

ASKER CERTIFIED SOLUTION
Avatar of AndrewJayPollack
AndrewJayPollack

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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!

A:="1";
B:="2";
C:="1":"2":"3";

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

@prompt([ok]; "test"; @Implode(result; "-"));
@Success
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 ?

LOL!
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.
Ad,

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.

-AP