Subj : Re: efficient searchs
To   : Ragnarok
From : Digital Man
Date : Sun Nov 27 2005 03:19 pm

 Re: Re: efficient searchs
 By: Ragnarok to Digital Man on Sun Nov 27 2005 07:55 pm

> Digital Man wrote:
>
> >   Re: efficient searchs
> >   By: Ragnarok to DOVE-Net.Sync_JavaScript on Fri Nov 25 2005 05:29 pm
> >
> >  >             msg.close();
> >  >         }
> >  >         else {
> >  >             writeln ("Error al abrir la base de mensajes: " +
> >  > msg_base.grp_list[grp].
> >  >         }
> >  >     }
> >  > }
> >
> > Your script seems to just search the message subjects. This is slow?
> >
> >                                                   digital man
> my idea is search in to body of messages too(in future), to put it into a
> web page, but i think to this will be more slow
> i can export the msgbase in timed events to mysql engine or make a cgi in
> c++ usign the msgbase api, but i dont know. i searching for ideas =?

I don't think any of that will be necessary.

Here's a variation on your script:

// search.js
// usage: jsexec search.js <msgbase_code> <search_string>

var msgbase_code = argv[0];
var search_string = argv[1];
var msgbase = new MsgBase(msgbase_code);
if(!msgbase.open()) {
       alert("Error " + msgbase.error + " opening msgbase: " + msgbase_code);
       exit();
}

var total_msgs = msgbase.total_msgs;
for(var i=0; i<total_msgs; i++) {
       var hdr = msgbase.get_msg_header(true,i);
       if(hdr.subject.indexOf(search_string)>=0)
               print(hdr.subject);
}
print("Searched " + total_msgs + " messages.");
msgbase.close();

Run with jsexec on a a message base with 5000+ messages:

Searched 5007 messages.
s:\sbbs\exec\search.js executed in 14.34 seconds

That's about 350 message headers a second. Is that considered slow?

                                                 digital man

Snapple "Real Fact" #5:
Camels have 3 eyelids.

---
� Synchronet � Vertrauen � Home of Synchronet � telnet://vert.synchro.net