Possible? Array of Notes Databases?

Trying to search multi db array, but I cannot get it function, it only sees the first db in the array. Im either defining the array wrong, OR this is not possible…Any ideas?

See earlier post: http://www-10.lotus.com/ldd/nd6forum.nsf/DateAllThreadedweb/663c055acc99623c85257292005cfb32?OpenDocument

We have a software tracking database, there is a request to be able to search the many knowledgebase (nsf) files by software name.

Thanks,

Jen

Subject: Possible? Array of Notes Databases?

Have u readup on multi database index?

This is the scenario it is made for.

Subject: Possible? Array of Notes Databases?

Hi,

Not sure if these helps…this is a very slimmed down version of what we use for our websearch:

Dim dbs As Variant,servers As Variant

Dim db As notesdatabase

Dim docs As NotesDocumentCollection

Dim doc As NotesDocument

Dim maxResults As Long, i As Long, ii As Long

Dim cSearch As String



dbs = Split("KB1,KB2,KB3",",")

servers = Split("server1,server1,server2",",")

cSearch = "<Some function to generate search or hardcoded>"

maxResults = 80 'or whatever you want the max on each database to be - or 0 for all docs



For i =0 To Ubound(dbs)

	Set db = New NotesDatabase( servers(i), dbs(i)+".nsf")

	Set docs = db.FTSearch(cSearch,maxResults)

	For ii = 1 To docs.count

		Set doc = docs.getnthdocument(ii)

		'Do something with the docs - We've created a special stack class to store links

		' to the documents, these are then ordered by score (doc.ftsearchscore) and 

		' output as one collection at the end

	Next

Next

…Obviously, we have a lot more code bolted onto this, but this is the basis of how it works. I can confirm that it works and has done for sometime.

We found multi-database indexes to be full of issues that we could not get round (that was when we used Notes5 and it might have got better since then but we’ve found the above code to be all we need).

Subject: RE: Possible? Array of Notes Databases?

Thanks for your response:

I have tried this out, but it never actually queries more than of the kbs listed, if I check the docs.count between the dbs, it only ever tells me a count for the first db.

Sub Click(Source As Button)

Dim dbs As Variant

Dim servers As Variant

Dim db As NotesDatabase

Dim docs As NotesDocumentCollection

Dim doc As NotesDocument

Dim maxresults As Long, i As Long, ii As Long

Dim csearch As String

	

Dim uiws As NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uiws = New NotesUIWorkspace

Set uidoc = uiws.CurrentDocument

Dim currentdoc As NotesDocument

Set currentdoc = uidoc.Document



dbs = Split("KB1.nsf", "KB2.nsf")

servers = Split("SERVER1")

csearch = currentdoc.Query(0)

maxResults = 0

	

For i =0 To Ubound(dbs)

Set db = New NotesDatabase( servers(i), dbs(i))

Set docs = db.FTSearch(csearch, maxResults)

For ii = 1 To docs.Count

Set doc = docs.GetNthDocument(ii)

Next

	

Next

Msgbox docs.Count

End Sub

Subject: RE: Possible? Array of Notes Databases?

Not sure if the problem is with the two lines:dbs = Split(“KB1.nsf”, “KB2.nsf”)

servers = Split(“SERVER1”)

Should be:

dbs = Split(“KB1.nsf,KB2.nsf”, “,”)

servers = Split(“SERVER1,SERVER1”, “,”)

…that could be a copy’n’paste error, rather than the code you are actually running? Have you checked whether the 2nd DB gets opened or not - with a msgbox db.filename or something?

The last line:

Msgbox docs.Count

Should always be equal to the number of docs found in the last DB, assuming it opens correctly and split functions creates the arrays as intended.

You’ll need to create some system of collating the results within the for…next loops. We use a user-defined class but a document list would suffice I suppose:

dim results LIST as NotesDocument

and then something along the lines of:

set results(cstr(i) & “,” & cstr(ii)) = doc