when you're smiling..

I can't stop smiling.

it's been quite an adventure, this php stuff. As well as the inevitable excercise my logic circuits have been getting, it's been throwing up all sorts of deeper, more philosophical questions. I'm not going into those, for now.

Back to the smiling.. now, while I was very happy with corzoogle, there were still things I wanted it to do, two things, in fact..

1) allow searching for multiple terms, and..

2) rank the results by relevance

The first one I reckoned would be easy, the second I wasn't so sure about. I decided that the best way to go about this would be to do what coders the world over do when faced with a challenge; check out how others did it.

So I started to download. There are quite a few search engine scripts "out there", ranging from dumb (not to mention totally insecure, and I have emailed the webmasters concerned, informing them that their admin passwords are available to any web browser, amazingly, only one has responded positively..) wee scriptlets to massive sprawling search systems spanning multiple folders and dozens of files, mysql intgration, the works. It was going to be a long night.

Some of the solutions to the ranking "issue" were quite ingenious, but few of these managed to achieve their ingenuity in anything like the number of lines of code I was prepared to add to corzoogle. I want it small, fast, and simple. Some of the examples I perused involved whole php classes with hundreds of lines of code peppered with the most bizarre regular expressions. regex is slow, and anyway, mine sucks, I didn't want to go there.

In the end (and I should add at this point that - and yes I am probably biased - none of these systems had the oomph factor and sheer simplicity that corzoogle has, nothing like it) I decided to abandon this line of enquiry and approach the problem afresh.

Right from the start, I've been deleloping three different versions of corzoogle (remember, I'm still in my php apprenticeship - I figured it would be good practice) utilising different search and scan techniques. I've abandoned two of those now, the remaining version always was the smallest, simplest, and fastest of the three, and it turns out, also the easiest to expand.

So why am I smiling? well, with typical cor-like style I not only succeeded in creating a beautiful and elegant solution to the whole ranking thing, but achieved it in two lines of code. yes, two. read 'em and weep noobs!

okay, three if you add the title ranking I slotted it afterwards.


What this means is..
Corzoogle will now search for an unlimited number of terms (in actual fact I put a 256 character limit on the input, fit in as many terms as you can into that - google limits their search queries to ten words, I might consider this route), and return only hits for pages containing all those terms, ranking them for you in the process.

The bottom line: Nine times out of ten, the page you want is right there at the top. Oh Lordy! I do rock!

So now corzoogle does exactly everything I wanted it to do. Once I've cleaned up my comments a bit (ie. removed the swear-words), I'll upload it to my (recently refurbished) scripts section. And you can get this working for you at home, or on your website.

Then you can flame me to hell and back for my arrogance!

for now..

:o) The Writing Entity @ corz.org

 ©  2024 « corz.org » 24.4.26  

Welcome to corz.org!

I'm always messing around with the back-end.. See a bug? Wait a minute and try again. Still see a bug? Mail Me!