NYCPHP Meetup

NYPHP.org

[nycphp-talk] Search function

(Margaret) Michele Waldman mmwaldman at optonline.net
Fri Sep 19 21:36:38 EDT 2008


Then, I would probably have to create a cron job to re-index the website
periodically?

I'm thinking the google custom search is much easier.

Thanks for the info though.

If I decide to be other-website-independent, I might do this.

Michele

-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of David Krings
Sent: Friday, September 19, 2008 9:32 PM
To: NYPHP Talk
Subject: Re: [nycphp-talk] Search function

(Margaret) Michele Waldman wrote:
> Thank you for your input.
> 
> I went to google.  Basically you need an xml file and some html.  They
> didn't break it down simply enough, but it was simply enough to figure out
> with slightly little effort.
> 
> Swish-e is not breaking through clearly enough quick enough for me.  Can
you
> break down the general idea?
> 
> It's looking like perl calls.  Is this the case?

As far as I recall there are two ways. You can either execute an ad-hoc
search 
and swish-e goes and digs through the files, or you can have it update a
site 
index on a schedule and then execute searches against that index. I found it

to be quite fast when I used it last and that was even by having swish-e 
create a temporary file (I think) that I then read in via PHP. The index
works 
OK unless you have so many changes going on on your site that the reindexing

would need to take place every minute and tie up resources.

The site where I used it on is still up and you can give it a try. Go to 
http://irsupport.net/search/search.htm and search for the word "lock". You
get 
an excessive amount of hits and yet the page still loads quickly. I may have

the code floating around somewhere, but would need to search for it. I did 
this years ago when I started with PHP and found it quite easy after
figuring 
out the command line parameters for swish-e. That site runs on WAMPP.

Well, I did have a good idea where I might have a backup of that code and I 
did find it. See the attached archive. It contains the search entry page as 
well as the script that executes the search against the index and then 
generates the results. I only looked at the first few lines, but it should
be 
well commented.

The documentation for how to create the index files is here: 
http://www.swish-e.org/docs/swish-run.html

HTH,

David




More information about the talk mailing list