Comment On The JavaScript Search Engine

You knew that it would only be a matter of time before some one would take our favorite scripting language, JavaScript, and try to build one of the most complex creations in computer science, a search engine. Andrew Taylor was browsing a certain company's website and noticed that their search function was wholly useless, but seemed to return results incredibly quickly, without even reshing the page. Curious as to what this might be, Andrew did a quick View Source and uncovered the JavaScript Search Engine ... [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: The JavaScript Search Engine

2005-11-14 13:11 • by 1st1
great stuff!

Re: The JavaScript Search Engine

2005-11-14 13:11 • by phuture


Re: The JavaScript Search Engine

2005-11-14 13:14 • by quamaretto
Well, that would understandably be *very* fast for a keyword search.



In fact, if the list of keywords was generated on the fly from the
contents of the site, this would approach being useful, and STILL be
lightning fast, except that then you would have a few hundred kilobytes
of Javascript array literals to download. But, that could be put in a
separate Javascript file and cached so it would only be downloaded
once...



Hell, I wouldn't be suprised if Ruby On Rails has a way to do this in three or four lines of code within a few months.

Re: The JavaScript Search Engine

2005-11-14 13:25 • by aaron

searchItems[0] = new Array
( "Initech Solutions :: Home",
   "index.htm",
   "The home page for Initech Solutions.",
   new Array (
     "home","initech","first","intro","introduction",
     "top","open","index","main","start")
);

has proberbly looped through a database table in serverside script and made the many arrays.  mabey it was a good idea when the site was new/or in testing when there were only a few products.  the search will always be instant but as the product count grows the page is going to keep taking longer and longer to load.


that said if the client/developer is on broadband downloading the site at 50k/sec then 1000 products will only take a few seconds to load.

Re: The JavaScript Search Engine

2005-11-14 13:26 • by Jeff S

If I were Google, I'd be nervous of this new technology! 


 

Re: The JavaScript Search Engine

2005-11-14 13:28 • by aaron
50530 in reply to 50529
isnt this what msn has been researching to compete in the search war

Re: The JavaScript Search Engine

2005-11-14 13:30 • by Satanicpuppy
This isn't that uncommon. Most of the time, when you have one of those dinky little search boxes on a web page, they're running a simple javascript.

I put one together for this site...The whole thing still hurts my mind, and I keep expecting it to show up on THIS site...anyway, I wrote a search function in javascript, that allowed the user to search content in  any of a couple hundred html pages...HARD CODED html pages, and it would return the most relevant results, based on the keywords associated with the page in the (again) hard coded Javascript search arrays.

The whole thing could have been done as a lark with a database and any scripting language, hosted for a song, and a million times better because you could update the content without having to manually update pages. The damn thing was supposed to be for a social index, so people were added and moved and all this junk, all the time. Total nightmare.

I tried so damn hard to convince the (neo-luddite) webdesigner to "experiment" with this "SQL" thing, but she refused utterly. Go figure.

Re: The JavaScript Search Engine

2005-11-14 13:31 • by BlackTigerX
is this the best WTF you could come up with today?

Re: The JavaScript Search Engine

2005-11-14 13:36 • by ammoQ
Pretty useless, but at least it's fast. I've seen worse than that
(extremely slow and still pretty useless). Done right, it might even
become semi-usefull.

Re: The JavaScript Search Engine

2005-11-14 13:37 • by eksortso

This sort of thing might work well for a small intranet, if it were properly indexed. (This one hardly seems to be!) I wouldn't use something like this if I was dealing with a site that was really huge or changed often. And like quamaretto said above, it would work better if searchItems were stored in a separate file.


There's an open-source project called Tipue that I've been using for an internal documentation site at my workplace. It does pretty much what this search engine does, except not as incompetently. Also, I wrote a custom indexing routine for it, even though the Tipue site comes with an indexing tool of its own.


Tipue is at http://www.tipue.com/ if anyone wants something like this that actually works. 

Re: The JavaScript Search Engine

2005-11-14 13:53 • by mrsticks1982
50536 in reply to 50529
Jeff S:

If I were Google, I'd be nervous of this new technology! 


 



Google probably bought it already ... say for a mere 1 Million Dollars

Re: The JavaScript Search Engine

2005-11-14 13:53 • by xenoputtss
This is fantastic!  The only problem that I see with this is that
the person viewing the website didn't know what they should search
for.  This is clearly not a WTF on the developer end, but more of
user error.   Jeesshh.  :-)

Re: The JavaScript Search Engine

2005-11-14 14:05 • by Anonymoose
50538 in reply to 50536
mrsticks1982:
Jeff S:

If I were Google, I'd be nervous of this new technology! 


 



Google probably bought it already ... say for a mere 1 Million Dollars





Not only did they buy it, they also made it work!

Go here, and start typing into the text box.  Fantastic.



http://www.google.com/webhp?complete=1&hl=en



Google Suggest

Re: The JavaScript Search Engine

2005-11-14 14:15 • by Otto
50540 in reply to 50538

Anonymoose:

Not only did they buy it, they also made it work!
Go here, and start typing into the text box.  Fantastic.

http://www.google.com/webhp?complete=1&hl=en
Google Suggest


Google Suggest actually hits their servers and retrieves an XML document... Every time you type a letter. The fact that they have more servers and bandwidth than God, Allah, and Buddha combined is what accounts for the fluidness of the functionality, because the idea verges close to a WTF, really.

Re: The JavaScript Search Engine

2005-11-14 14:17 • by Satanicpuppy
50541 in reply to 50534
Anonymous:

This sort of thing might work well for a small intranet, if it were properly indexed. (This one hardly seems to be!) I wouldn't use something like this if I was dealing with a site that was really huge or changed often. And like quamaretto said above, it would work better if searchItems were stored in a separate file.


There's an open-source project called Tipue that I've been using for an internal documentation site at my workplace. It does pretty much what this search engine does, except not as incompetently. Also, I wrote a custom indexing routine for it, even though the Tipue site comes with an indexing tool of its own.


Tipue is at http://www.tipue.com/ if anyone wants something like this that actually works. 



Tipue is good 'ware, but the whole thing is staticly indexed which makes it a pain to keep current. If your hosting is good enough, you can get a script that'll do the indexing for you but if you can have a script on the site that can write to files then there has to be a better way than using a javascript search. They get bulky real quick.

Re: The JavaScript Search Engine

2005-11-14 14:28 • by foxyshadis
50542 in reply to 50540
Otto:

Anonymoose:

Not only did they buy it, they also made it work!
Go here, and start typing into the text box.  Fantastic.

http://www.google.com/webhp?complete=1&hl=en
Google Suggest


Google Suggest actually hits their servers and retrieves an XML document... Every time you type a letter. The fact that they have more servers and bandwidth than God, Allah, and Buddha combined is what accounts for the fluidness of the functionality, because the idea verges close to a WTF, really.


The source code is the real wtf. How many two-letter variables can you stuff into one file?
http://www.google.com/ac.js
I remember trying to puzzle out exactly what it did when it first came out, before I just got sick of translating and just reinvented it from scratch.

I know what this wtf's problem is, it doesn't return enough pages. Everything should be indexed with every word on their pages. That way when someone searches for their main product, they get every page! Yes!

Re: The JavaScript Search Engine

2005-11-14 14:33 • by reinpost
50543 in reply to 50531
I don't understand, Satanicpuppy ... you could have preprocessed the SQL queries and the web designer wouldn't even have known about it.

Re: The JavaScript Search Engine

2005-11-14 14:45 • by kipthegreat
Why do they need javascript at all?  Why not just print everything to the page and tell the user to press Ctrl-F??



Sincerely,

Sprio Agnew

Re: The JavaScript Search Engine

2005-11-14 14:45 • by loneprogrammer
50545 in reply to 50543
This is actually a fairly useful idea, if the search actually is able to find what you want.



This site:

http://perldoc.perl.org/



has a javascript search feature, and it actually finds things, since
the search index covers things like every Perl function and module name.



If the search comes back with no results, you just click one more
button, and it does a Google search with your search terms, so if you
are searching for something not in the index, you aren't left hanging.



You can even download the entire website as a .tar.gz archive, and the
search feature still works, since it never contacts the server!



It's also good for offline use.



Re: The JavaScript Search Engine

2005-11-14 15:04 • by Xepol

Not seeing the problem personally.  It is a simple keyword search.  Assuming that the search engine ONLY works with keywords, it hardly matters if it is client side processed or not.


While it MIGHT be a waste of bandwidth, it is fast and efficent for searching the keywords that are registered.   If the site uses HTTP compression, the wasted bandwidth like likely negligable and is still probably smaller than the HTML file without the embeeded javascript for searching.


We're all spoiled by Google.  Not every situation requires that you be able to search for the phrase "rabid gophers in heat" and expect to get plumbing references - sometimes a simple keyword search is enough to cover the basics.


True, Google even provides tools for doing site specific searching, sometimes you don't want to flood people with results. (oh, the site searchs I have seen, and how useless they were when all I wanted to do was search titles...)  Write to your audience, and I'll bet the site search is a damn good fit for 99% of their visitors, esp. if the site is technical in nature.

Re: The JavaScript Search Engine

2005-11-14 15:08 • by Bustaz Kool
50547 in reply to 50531

Satanicpuppy:
I tried so damn hard to convince the (neo-luddite) webdesigner to "experiment" with this "SQL" thing, but she refused utterly. Go figure.


Kudos for using "Luddite" and "Webdesigner" to describe the same person.  Nice touch!

Re: The JavaScript Search Engine

2005-11-14 15:12 • by Casiotone
50548 in reply to 50542
Saving bandwidth is a WTF?

Re: The JavaScript Search Engine

2005-11-14 15:12 • by Casiotone
50549 in reply to 50542
Gah, that was supposed to be quoting this:

foxyshadis:

The source code is the real wtf. How many two-letter variables can you stuff into one file?
http://www.google.com/ac.js
I
remember trying to puzzle out exactly what it did when it first came
out, before I just got sick of translating and just reinvented it from
scratch.

I know what this wtf's problem is, it doesn't return
enough pages. Everything should be indexed with every word on their
pages. That way when someone searches for their main product, they get
every page! Yes!


Re: The JavaScript Search Engine

2005-11-14 15:15 • by Anonymoose
50550 in reply to 50546
Xepol:

(oh, the site searchs I have seen, and how useless they were when all I wanted to do was search titles...)





That reminds me of searching MSDN for... anything. What a friggin'
useless piece of crap search engine.  I almost always end up back
at Google, and enter site:msdn.microsoft.com as a search term.



Can't wait for Microsoft to try and compete with Google, on the search front!

Re: The JavaScript Search Engine

2005-11-14 15:29 • by eksortso
50551 in reply to 50541

Satanicpuppy:

Tipue is good 'ware, but the whole thing is staticly indexed which makes it a pain to keep current. If your hosting is good enough, you can get a script that'll do the indexing for you but if you can have a script on the site that can write to files then there has to be a better way than using a javascript search. They get bulky real quick.


I agree. This sort of thing works well for documentation sites that don't change very often. The Tipue site recommends using their search engine on sites that don't exceed 50 pages. The perldoc site is like that, even though Perl's documentation pages are freakin' huge.


It would be nice to have a full-fledged search engine on my company's intranet, but it's overkill for us. Tipue works well enough for my purposes, even if the index is bulky (about 200KB, which isn't so bad over a local network).

Re: The JavaScript Search Engine

2005-11-14 15:38 • by MikeB
Don't tell the guys at thunderstone (aka www.master.com). Webinator is looking pretty lame after this.

Re: The JavaScript Search Engine

2005-11-14 15:57 • by masklinn
50554 in reply to 50542
foxyshadis:
The source code is the real wtf. How many two-letter variables can you stuff into one file?
http://www.google.com/ac.js
I remember trying to puzzle out exactly what it did when it first came out, before I just got sick of translating and just reinvented it from scratch.

I know what this wtf's problem is, it doesn't return enough pages. Everything should be indexed with every word on their pages. That way when someone searches for their main product, they get every page! Yes!

Not a WTF at all, the file simply went through a compressor/obfuscator that removes all the whitespaces and renames variables to both reduce drastically the file size (can come in handy when you're Google and you might be serving the little javascript thing 50 millions times a day if it ever hits live servers) and make the code slightly harder to reverse engineer. Check Chris Justus' Google Suggest Dissected for an "unobfuscated" version.


Re: The JavaScript Search Engine

2005-11-14 16:02 • by masklinn
50555 in reply to 50554
masklinn:
foxyshadis:
The source code is the real wtf. How many two-letter variables can you stuff into one file?
http://www.google.com/ac.js
I remember trying to puzzle out exactly what it did when it first came out, before I just got sick of translating and just reinvented it from scratch.

I know what this wtf's problem is, it doesn't return enough pages. Everything should be indexed with every word on their pages. That way when someone searches for their main product, they get every page! Yes!

Not a WTF at all, the file simply went through a compressor/obfuscator that removes all the whitespaces and renames variables to both reduce drastically the file size (can come in handy when you're Google and you might be serving the little javascript thing 50 millions times a day if it ever hits live servers) and make the code slightly harder to reverse engineer. Check Chris Justus' Google Suggest Dissected for an "unobfuscated" version.


Oh yeah, to answer your question that would be 26+26*36 = or 24336 different variables. And that's only taking in account alphanumerics, i think you can also use characters such as "_", "$", "è" or "µ" to name your variables in Javascript.

Re: The JavaScript Search Engine

2005-11-14 16:19 • by Anonymous
50556 in reply to 50555
Why does everyone hate on JavaScript so much here?

Re: The JavaScript Search Engine

2005-11-14 16:30 • by quamaretto
50557 in reply to 50556
Anonymous:
Why does everyone hate on JavaScript so much here?




I'm not sure who here does that. In web design, Javascript is the
solution to a certain set of problems involving interactivity in web
pages. It is also useful as a general high-level scripting and
programming language, but only Mozilla and Macromedia and some
hobbyists have figured this out.



Searching large amounts of data, in the client's web browser, is not really a proper job for Javascript.



Part of the reason that so much bad Javascript shows up on the site is
because it is written by designers and other relatively uneducated
peoples, and somewhat less because the knowledge base (popular books
and web sites) is so rampant with misinformation, bad hacks and general
crap that even good programmers would have a hard time finding best
practices.





Re: The JavaScript Search Engine

2005-11-14 16:46 • by ItsAllGeekToMe
50559 in reply to 50556

Anonymous:
Why does everyone hate on JavaScript so much here?


 


Because.  It sucks more than anything's ever sucked before.

Re: The JavaScript Search Engine

2005-11-14 17:01 • by ammoQ
50561 in reply to 50556
Anonymous:
Why does everyone hate on JavaScript so much here?


Several possibilities...

a) It's an extremely cheap clone of an already poor language.

b) It grew in an unhealthy way and lacks a proper concept.

c) It's used for things it shouldn't be used.

d) It's used by people who shouldn't use it.

e) Real programmers might actually be forced to use it.

Re: The JavaScript Search Engine

2005-11-14 17:04 • by Monday
50562 in reply to 50561
It has it's place.

-Form validation without reloading a age.
-ummm....
-ummmmmmmm.......
-Form vali...oh wait. Crap.

-Dynamic forms. Yes! I knew I had one more!

Re: The JavaScript Search Engine

2005-11-14 17:10 • by Gorm Braaarvig
50563 in reply to 50540

I've done this for a year before google suggest.


http://firmakatalogen.com/


With a single server (bad lines, so latency could be an issue).
Just 10M rows, though. Still, you get the results here, not only the words...

Re: The JavaScript Search Engine

2005-11-14 17:16 • by clockwise
50564 in reply to 50563
There is no way this is a WTF. This is a quick and nasty solution. But I like it. It's fast, it's on the client side, and it's pretty easy to maintain. Please try a little bit harder Alex.

Re: The JavaScript Search Engine

2005-11-14 17:51 • by Florian
50565 in reply to 50561
ammoQ:
Anonymous:
Why does everyone hate on JavaScript so much here?


Several possibilities...

a) It's an extremely cheap clone of an already poor language.



Common Lisp is poor in what respect, again?



b) It grew in an unhealthy way and lacks a proper concept.


It is one of the few languages that do in fact have a formal semantics,
so it is among the healthiest languages out there (that does not imply
that the implementations are healthy, too).





c) It's used for things it shouldn't be used.


Yes





d) It's used by people who shouldn't use it.


Indeed





e) Real programmers might actually be forced to use it.


It isn't actually that bad, it is the browsers that suck.

Re: The JavaScript Search Engine

2005-11-14 18:03 • by Gene Wirchenko
50568 in reply to 50528
Anonymous:
that said if the client/developer is on
broadband downloading the site at 50k/sec then 1000 products will only
take a few seconds to load.




What about the user?



Some software companies have had the standard of their software being usable on an older system as a counter to bloat.



Sincerely,



Gene Wirchenko



Re: The JavaScript Search Engine

2005-11-14 18:09 • by Gene Wirchenko
50569 in reply to 50550
Anonymoose:
That reminds me of searching MSDN for... anything. What a friggin'
useless piece of crap search engine.  I almost always end up back
at Google, and enter site:msdn.microsoft.com as a search term.




Thank you for the tip.  Searching Microsoft Websites has not been pleasant for me either.



Can't wait for Microsoft to try and compete with Google, on the search front!




First, they will have to find their butts with both hands.  (That unpleasantness has been really unpleasant.)



Sincerely,



Gene Wirchenko



Re: The JavaScript Search Engine

2005-11-14 18:13 • by Alf
50570 in reply to 50540
Otto, thats called AJAX... google it (heh) so you can realise that the wtf here, is you thinking that ajax is a wtf....
Welcome to 2005....

Re: The JavaScript Search Engine

2005-11-14 18:28 • by foxyshadis
50571 in reply to 50559
ItsAllGeekToMe:

Anonymous:
Why does everyone hate on JavaScript so much here?


 


Because.  It sucks more than anything's ever sucked before.


XSLT gives it a good run for its money though. Someone needs to come up with a XSLJScript fusion language that requires constant use of eval() and dynamic:evaluate() (the xslt version) and transitions between the interpreters several layers deep. Use it to build a custom SQL-like database.

The top faq for the site would be "in order to use our site, you must increase your browser http time-out".

Casiotone:
Saving bandwidth is a WTF?

With http compression there would be almost no difference, in plain text would be about half again the size. Besides which, as stated, google has all the bandwidth in the universe and then some. I just made the point that it looks like a bizarre wtf made by someone who doesn't realize languages accept for than two letters per variable (yes, I know full well it was intentionally obfuscated).

masklinn: Javascript is case-sensitive. ie, 52+52*62. (I leave gathering a list of all legal characters as an exercise to the reader.)

Re: The JavaScript Search Engine

2005-11-14 18:30 • by foxyshadis
50573 in reply to 50570
Anonymous:
Otto, thats called AJAX... google it (heh) so you can realise that the wtf here, is you thinking that ajax is a wtf....
Welcome to 2005....


The real magic of AJAX is that it lets people like you build a framework to hit the server with a XML request and recieve one back everytime the mouse moves.

Re: The JavaScript Search Engine

2005-11-14 19:12 • by robbak
50574 in reply to 50550
Anonymoose:
Xepol:

(oh, the site searchs I have seen, and how useless they were when all I wanted to do was search titles...)





That reminds me of searching MSDN for... anything. What a friggin'
useless piece of crap search engine.  I almost always end up back
at Google, and enter site:msdn.microsoft.com as a search term.



Can't wait for Microsoft to try and compete with Google, on the search front!


Which reminds me that the local host of "Who Wants to be a Millionare"
is always referring to "ninmsn search" if he gets the idea that a
phone-a-friend was searching the internet. I'm waiting for someone to
tell him that he'd be glad to, if he gave them 30 minutes to come up with something!

Re: The JavaScript Search Engine

2005-11-14 19:26 • by Otac0n
50575 in reply to 50574

I have actually been guilty of creating this kind of search engine :(


 

Re: The JavaScript Search Engine

2005-11-14 19:54 • by qu1j0t3
50576 in reply to 50561
ammoQ: a) It's an extremely cheap clone of an already poor language.

Which language would that be, then?
Anonymoose: searching MSDN for... anything. What a friggin' useless piece of crap search engine.

That's been my consistent experience also.

Re: The JavaScript Search Engine

2005-11-14 21:38 • by Alf
50577 in reply to 50573

foxyshadis:
Anonymous:
Otto, thats called AJAX... google it (heh) so you can realise that the wtf here, is you thinking that ajax is a wtf....
Welcome to 2005....


The real magic of AJAX is that it lets people like you build a framework to hit the server with a XML request and recieve one back everytime the mouse moves.


 


And why would i do that, i currently use Ajax only on some combobox in the intranet web page where i work... useful to update info on the page without having an anoying pageload...


Tell me, why on earth would i use ajax for mouse move events? And do you know me or anything.....


Have a look at telerik's website, they have some pretty nice asp.net controls using Ajax (www.telerik.net) which dont actually query the server on every mouse move....


Thanks for being an ass

Re: The JavaScript Search Engine

2005-11-14 22:34 • by Jason Kester
50578 in reply to 50577
Tell me, why on earth would i use ajax for mouse move events?

check out http://www.ktracker.com for an application that does exactly that. It's a usability tool that lets you watch visitors using your site by actually replaying their sessions.


Jason

Re: The JavaScript Search Engine

2005-11-15 01:28 • by Drak
50580 in reply to 50575
Otac0n:

I have actually been guilty of creating this kind of search engine :(


 



Well, I did do something similar here: http://ghostrecon.tacticalnet.org/search.html


Except that it does not use arrays for searching but and XML file.


Oh and IE only, sorry about that... And the normal View Source isn't going to make too much sense.


Drak

Re: The JavaScript Search Engine

2005-11-15 03:06 • by Andrey
But does it support regular expressions?

Re: The JavaScript Search Engine

2005-11-15 03:33 • by ammoQ
50584 in reply to 50565
Florian:
ammoQ:
Anonymous:
Why does everyone hate on JavaScript so much here?


Several possibilities...

a) It's an extremely cheap clone of an already poor language.



Common Lisp is poor in what respect, again?



JavaScript a clone of ((common) (lisp))? (((Hard) to) (believe) - (((something) (is)) missing)) ;-)





b) It grew in an unhealthy way and lacks a proper concept.


It is one of the few languages that do in fact have a formal semantics,
so it is among the healthiest languages out there (that does not imply
that the implementations are healthy, too).


Having formal semantics is enough to qualify as "healthy"? That's so sad...


Re: The JavaScript Search Engine

2005-11-15 04:21 • by brazzy
50586 in reply to 50548
Casiotone:
Saving bandwidth is a WTF?




If you mean the original WTF: yes, because it does NOT save bandwidth -
quite the opposite, in fact. All the keywords and stuff are transmitted
every time the page is loaded,
making it considerably bigger than it would otherwise be - and the
search feature will probably not be used upwards of 95% of the time.

« PrevPage 1 | Page 2 | Page 3Next »

Add Comment