Tip

Fast Notes searches on database over Web

Awesome fast, easy and efficient searches on a Notes database over the web using javascript. A client had requested that we create search functionality for our Corporate directory. The key was that they wanted a custom look on the page and that the search be applied to only certain fields in this database and that the results be displayed in alphabetical order without the relevence boxes?. Outch! We tried to build the search in Lotusscript? it seemed to work great at first, but as soon as we added any type of user load it would take a long time to return the results (3-4 minutes), it's a huge database. We then tried the following method which has worked like a charm! Enjoy!



"Elements involved:
Search form where the entry field is contained: SideBar
The search results form: $$SearchTemplate for WebSearch
View that will contain the search results: (WebSearch)

I added this script around the $$ViewBody in the $$SearchTemplate for WebSearch:
<script>

sortit=new Array();
j=0;
$$ViewBody
sortit.sort();
document.writeln("<Table>");
for (i = 0; i < sortit.length ; i++)
{

ss = sortit[i].toString();
pos = ss.indexOf("[");
disp = ss.substr(pos+1);
document.write(disp);

}
document.write("</Table>");

</script>


I have a field called ?namesearch? where the user will enter a name to search on:
?namesearch? (editable text field)

In the form where the user is entering the name to search on, the following code must be added to the $$Return This code builds the url to be used in the search that will bring back the specific info we need from designated fields only.


criteria := @If(@Contains(namesearch;" ");@ReplaceSubstring(namesearch;"
";"+OR+");namesearch);

"<script>history.back();
parent.Body.window.location="/Corporate+Directory/Corporate.nsf/WebSearch/?S
earchView&Query="+"[LastName]"+"+CONTAINS+"+
"("+criteria+")"+"+OR+"+"[FirstName]"+"+CONTAINS+"+
"("+criteria+")"+"+OR+"+"[givenName]"+"+CONTAINS+"+
"("+criteria+")"+"+OR+"+"[Seat]"+"+CONTAINS+"+
"("+criteria+")"+"+OR+"+"[NABUserID]"+"+CONTAINS+"+
"("+criteria+")"+"";self.location.reload()</script>

In the view ?(WebSearch)? I added the following code to the first column that displays the information to the web client? all the HTML formatting is used to display the information returned in a pleasing manner:


"sortit[j]="" + LastName + "," + FirstName + "[" +
@Trim("

This was first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.