Possible SearchOrder=4 Workaround

For those not familiar with this issue, the Search URL’s used with Domino support a parameter to control the sort of search results returned by a query, SEARCHORDER and from the docs…

SearchOrder=[1,2,3,4]

Indicate 1 to “Sort by relevance”, 2 to “Sort by date ascending”, 3 to “Sort by date descending.” The default is 1. SearchView also supports a SearchOrder value of 4 to “Keep current order”, which sorts the resulting set of documents in the order in which they appear in the view.

Option 4(Keep Current Order) is misleading and does not work as expected when returning anything less than the full search results on one page. This issue appears in R5 and R6 servers, with no sign of a fix or SPR. Oddly enough, it IS noted in the 6.5b1 Release Notes under SPR TRACKING ID: BFRD4XLMHK - but it is indicated as “not fixed” (If anyone gets tries the beta, please post your findings)

Proposed Solution

Here is a proposed workaround we tried for a client running an e-commerce site on Domino.

Create a view sorted by the desired field and sort order. Then use an agent to loop through all the documents in the view in order, resaving each document as you go, pausing for 2 seconds between saves. Then make sure the FT Index is updated. Now you can use SEARCHORDER=2 in your URLs, which will return your search results in date descending order, which now happens to be the same order as the original sort order of your view.

Of course, there are many cons to this approach. For example, if your documents are edited frequently, the sort order will be incorrect until the agent can be run again. But for certain situations where documents are relatively static (such as a product catalog), this approach should provide some relief until Lotus decides to get this right.

An example agent is listed below which looks for a view ‘Title’ that’s alpha sorted by the title field, and then resaves all the docs in the view so that the date descending order matches the view sort order as previously described.

Vince Mennella

Cygnus Technologies

www.cygnustech.net

==============================================================

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim entry As NotesViewEntry

Dim nav As NotesViewNavigator

Dim doc As NotesDocument

On Error Goto errHandler

Set db = session.CurrentDatabase

Set view = db.GetView(“Titles”)

Call view.Refresh

view.AutoUpdate=False

Set nav = view.CreateViewNav

Set entry = nav.Getfirstdocument()

While Not entry Is Nothing

Set doc = entry.Document

Set entry = nav.GetNextDocument(entry)

doc.timer = Cstr(Timer) 'force a change to the doc

Call doc.Save(True,False)

Print doc.title(0)

Sleep(2)

Wend

Sleep(5)

db.UpdateFTIndex(True)

Exit Sub

errHandler:

Print Cstr(Erl)

Exit Sub

End Sub

Subject: SearchOrder=4: The final word in the release notes 6.5.1

The post above with the SPR tracking ID made it possible to identify a release note in the 6.5.1 release notes. The disappointing message is that it is a “user misunderstanding”, in other words, a fix cannot be expected. For more info, read here:

http://www-12.lotus.com/ldd/doc/domino_notes/6.5.1/readme651.nsf/Main?OpenFrameSet&Frame=Target&Src=%2Fldd%2Fdoc%2Fdomino_notes%2F6.5.1%2Freadme651.nsf%2F95cf8f3b7f04b64c8525676e006db3df%2F5bfdac9f47b9b42385256e5c005ce428%3FOpenDocument%26AutoFramed