Dbsearch or ftsearch?

I’m trying to figure out which one to use: dbsearch or ftsearch.

I’m going to use relational operators in the formula so I believe “ftsearch” is the one I should use?

I need to get a collection of documents between 2 numbers.

Has anyone seen examples of this? I’m only seeing examples between 2 dates.

Thanks!!!

Subject: dbsearch or ftsearch?

If a new document is created in the database which has not been indexed, will not appear in ftsearch result even it fullfills the search criteria.A document is eligible to appear in ftsearch only when ftsearch activity has been performed for the document.While an db.search is like an view selection formula which will show up all documents as per the search criteria even if the document is indexed or not.

But db.search would consume more time and decreases perfomrance as compared to ftsearch.

Full text indexing helps in faster searching and maintaning an index of the text.

Subject: RE: dbsearch or ftsearch?

The db is not even 1 mb, has only 200 docs in it. I’m not really concerned with performance really unless searches take over 30 seconds maybe or more.

I can index the db, no problem. I’m trying to figure out which one is best for relational operators, getting a collection between 2 numbers.

Thanks for the reply!!!

Subject: RE: dbsearch or ftsearch?

Bill,

Do you mean something like this?

set dc = db.Search ( {Form = “Main” & NumberField > 2 & NumberField < 4}, dateTime, 0 )

There are numerous things to think about in terms of performance, but I agree that any db with less than 10k docs and smaller than 10mbs doesn’t really need to worry about that aspect.

regards,

raphael

Subject: RE: dbsearch or ftsearch?

Raphael,

Yes, I’m looking for something like this sorta.

I have two input boxes that will have numbers. I need all docs in between the 2 values.

Subject: need help with the search code…section (code posted)

Here is what I have so far. I know there is something wrong with the search part. It needs to search based off the 2 input box results. Thanks for any help!!!


Sub Click(Source As Button)

Dim beginning As String

Dim ending As String

'User enters beginning MOR…

askbeginningagain:

beginning = Inputbox$("Enter beginning MOR", "Search")

If beginning = "" Then

	Msgbox "Lab Search Canceled.", MB_OK, "Search"

	Exit Sub

	num% = Cint(beginning)

End If

If Not Isnumeric(beginning) Then

	Msgbox "Only numbers are allowed, try again please.", MB_OK, "Search"

	Goto askbeginningagain

End If

'User enters ending MOR…

askendingagain:

ending = Inputbox$("Enter ending MOR", "Search")

If ending = "" Then

	Msgbox "Lab Search Canceled.", MB_OK, "Search"

	Exit Sub

	num% = Cint(ending)

End If

If Not Isnumeric(ending) Then

	Msgbox "Only numbers are allowed, try again please.", MB_OK, "Search"

	Goto askendingagain

End If

'Now collect the documents based on beginning and ending MOR and display for the user…

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim session As New notessession

Dim db As NotesDatabase

Set db = session.currentdatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument, doc2 As NotesDocument

Dim rtitem As NotesRichTextItem



SearchStrings$ = ( {Form = "LR" & bulkdensity > beginning & bulkdensity < ending}, dateTime, 0 )

Set collection = db.FTSearch(SearchString$, 0)

Msgbox "There are" & collection.count & "document(s) greater than " & beginning & "less than " & ending &"."



If collection.count = 0 Then

	Exit Sub

End If



If collection.Count > 0 Then

	

	Set doc2 = db.CreateDocument

	doc2.form = "Report"

	Set rtitem = New NotesRichTextItem(doc2, "Link")

	'.......populate doc2 fields.....

	'..........................................

	'..........................................

	'..........................................

	'..........................................

	'..........................................

	Set doc = collection.GetFirstDocument

	Do Until doc Is Nothing

	End If

	

Next



Set doc = collection.GetNextDocument(doc)

Loop

Call rtitem.Update

Set uidoc = ws.EditDocument(False, doc2)

End If

End Sub

Subject: RE: need help with the search code…section (code posted)

Bill,

Maybe this …

SearchStrings$ = ( {Form = “LR” & bulkdensity > “} & beginning & {” & bulkdensity < “} & ending & {”}, dateTime, 0 )

You’ve Dim’d beginning/ending as strings, but if you want to treat them as numbers then maybe you need

SearchStrings$ = ( {Form = “LR” & bulkdensity > @TextToNumber(} & beginning & {) & bulkdensity < @TextToNUmber(} & ending & {)}, dateTime, 0 )

Combining variables from LS and the document in search strings are always a bit tricky, but I think one or both of the above will help.

regards,

raphael

Subject: RE: need help with the search code…section (code posted)

Raphael, your use of @TextToNumber here is incorrect; the formula is all a string; if it contains the digits 6 and 7, that’s the number 67. It doesn’t matter how a variable was declared in the script.

For best performance, I would always use FTSearch if you can afford to store the full-text index, and if the FT syntax supports the search you want to do. Search method has to look at every document in the database (subject to the date you specify). FTSearch uses its index to quickly find the documents without having to look at non-matching documents.

Another option that wasn’t discussed is to use a view that’s sorted by the value you want to search on. This is very fast (though it’s easier to search for a specific value this way than a range, where you would have to program your own binary search).

Subject: RE: need help with the search code…section (code posted)

Andre,

Per the size of the db, I think the issue of performance is moot. Not that I disagree with your premise that ftsearch is faster in most cases, just that it’s not relevant in this case.

I checked my code, and rewrote it to be less buggy :wink:

This code correctly finds the documents which have bulkdensity greater than 2 and less than 4. I just ran the code in a test db. If bulkdensity is really two fields, that’s an easy change. And I’m not bothering with user input to set my parameters because it was just a proof of concept.

Dim s As New notessession

Dim db As notesdatabase

Set db = s.CurrentDatabase



Dim dc As NotesDocumentCollection

Dim dateTime As New NotesDateTime ( "1/1/2007" )



Dim beginning As String

Dim ending As String

beginning = "2"

ending = "4"



Set dc = db.search ( {Form = "LR" & bulkdensity > @TextToNumber("} & beginning & {") & bulkdensity < @TextToNUmber("} & ending & {")}, dateTime, 0 )

regards,

raphael

Subject: RE: need help with the search code…section (code posted)

Raphael,

Am I doing something wrong here? The collection always shows 0.

There is only one bulkdensity field on my form by the way.


Sub Click(Source As Button)

Dim beginning As String

Dim ending As String

'User enters beginning MOR…

askbeginningagain:

beginning = Inputbox$("Enter beginning MOR", "Search")

If beginning = "" Then

	Msgbox "Lab Search Canceled.", MB_OK, "Search"

	Exit Sub

	num% = Cint(beginning)

End If

If Not Isnumeric(beginning) Then

	Msgbox "Only numbers are allowed, try again please.", MB_OK, "Search"

	Goto askbeginningagain

End If

'User enters ending MOR…

askendingagain:

ending = Inputbox$("Enter ending MOR", "Search")

If ending = "" Then

	Msgbox "Lab Search Canceled.", MB_OK, "Search"

	Exit Sub

	num% = Cint(ending)

End If

If Not Isnumeric(ending) Then

	Msgbox "Only numbers are allowed, try again please.", MB_OK, "Search"

	Goto askendingagain

End If

'Now collect the documents based on beginning and ending MOR and display for the user…

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim session As New notessession

Dim db As NotesDatabase

Set db = session.currentdatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument, doc2 As NotesDocument

Dim rtitem As NotesRichTextItem

Dim dateTime As New NotesDateTime ( "1/1/2007" )



Set collection = db.search ( {Form = "LR" & bulkdensity > @TextToNumber("} & beginning & {") & bulkdensity < @TextToNUmber("} & ending & {")}, dateTime, 0 )

'Set collection = db.FTSearch(SearchString$, 0)



Msgbox "There are " & collection.count & " documents with MOR greater than " & beginning &" and less than " & ending &".", MB_OK, "Search"



If collection.count = 0 Then

	Exit Sub

End If





If collection.Count > 0 Then

	

	Set doc2 = db.CreateDocument

	doc2.form = "Report"

	Set rtitem = New NotesRichTextItem(doc2, "Link")

	'.......populate doc2 fields.....

	'..........................................

	'..........................................

	'..........................................

	'..........................................

	'..........................................

	Set doc = collection.GetFirstDocument

	Do Until doc Is Nothing

'	End If

		

' Next

		

		Set doc = collection.GetNextDocument(doc)

	Loop

	

	Call rtitem.Update

	Set uidoc = ws.EditDocument(False, doc2)	

	

End If

End Sub

Subject: RE: need help with the search code…section (code posted)

I had the field on my form as “text”. Let me see if this helps!

Subject: RE: need help with the search code…section (code posted)

So are you saying I should I use GetAllDocumentsByKey instead? Is that the better way around? How do you make keys though so it finds all docs between 2 keys?


Dim view As NotesView

Set view=db.Getview("viewname")

Dim collection As NotesDocumentCollection

Set collection = view.GetAllDocumentsByKey(key,True) 

If collection.count = 0 Then

Msgbox “No documents found between the values”

	Exit Sub

If collection.count > 0 Then

	Set doc2 = db.CreateDocument

	doc2.form = "formname"