[PHP] Re: PHP/MySQL Search Engine Query Question
I am currently working on a website that is implemented using PHP and MySQL. The site currently has a simple search engine that allows a shopper to type in a search string that is stored in $search. For example, if a shopper types in 1972 Ford Mustang $string =1972 Ford Mustang Using the following SQL statement: SELECT * FROM whatevertable WHERE whatevercolumn LIKE '%$search% Records are returned that have this exact string and in this exact order (I'm aware a wild card character is included on the front and back of the string). My desire is to be able to logically AND each token of the search together independent or the order of the tokens. I want to return all records that have Mustang AND 1972 AND Ford. Since a shopper inputs the search string in advance I don't know how many tokens will be used. How about using OR and a ranked sorting so that the more words that match, the better? ?php if (!isset($start)){ $start = 0; # Or is it 1? MySQL/PostgreSQL do it differently. G. } $words = explode(' ', $search); $query = select whatever, 0 ; while (list(,$word) = each($words)){ if (trim($word)){ $query .= + whatevercolumn LIKE '%$word%' ; } } $query .= as score ; $query .= from sometable ; $query .= where score 0 ; $query .= order by score desc ; $query .= limit $start, $limit ; ? Since LIKE returns TRUE/FALSE, when you add them up they turn into 1/0, and you get a one-point score for each matching word. -- Like Music? http://l-i-e.com/artists.htm I'm looking for a PRO QUALITY two-input sound card supported by Linux (any major distro). Need to record live events (mixed already) to stereo CD-quality. Soundcard Recommendations? Software to handle the recording? Don't need fancy mixer stuff. Zero (0) post-production time. Just raw PCM/WAV/AIFF 16+ bit, 44.1KHz, Stereo audio-to-disk. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP based search engine
David Robley wrote: PHP from around 4.05 has functions available to interface with the mnoGOSearch search engine, available from http://www.mnogosearch.ru/ I recommend you look at this combination. I recommend this one to, its a very good alternative which I used for several projects. The nice thing is that you can easily update and keep the index updated by yourself, no need for that stupid indexer that comes along to crawl around your site. I have a small script which inserts new keywords/descriptions/titles directly in the index on update of something that should be searchable. This is probably easiest to do when you're using a database as a backend for the search. Another soloution is to have a hourly cronscript that updates the index. I have used that on bookmarks.egp.cx . Since I have a modification timestamp on each link there I only need to update those who where changed since the last indexinground. Often there are no links modified in the last hour, so its not very resourcehungry, but that depends on the data off course. :) Just my ideas. :) Good luck! Eric -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP based search engine
I've gone to the mnoGoSearch page - it does look like it would do the job nicely, however my hosting company absolutely refuses to upgrade to anything above PHP 3.0.16, also it appears as though I'd have to compile a good portion of mnoGoSearch on the server itself - another thing I'm not allowed to do. I think I've got the Fluid Dynamics search engine working fairly well now - its not perfect, but it'll do until I can come up with something better. Thanks -Tim At 11:39 AM 3/13/2002 +0100, you wrote: David Robley wrote: PHP from around 4.05 has functions available to interface with the mnoGOSearch search engine, available from http://www.mnogosearch.ru/ I recommend you look at this combination. I recommend this one to, its a very good alternative which I used for several projects. The nice thing is that you can easily update and keep the index updated by yourself, no need for that stupid indexer that comes along to crawl around your site. I have a small script which inserts new keywords/descriptions/titles directly in the index on update of something that should be searchable. This is probably easiest to do when you're using a database as a backend for the search. Another soloution is to have a hourly cronscript that updates the index. I have used that on bookmarks.egp.cx . Since I have a modification timestamp on each link there I only need to update those who where changed since the last indexinground. Often there are no links modified in the last hour, so its not very resourcehungry, but that depends on the data off course. :) Just my ideas. :) Good luck! Eric -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP based search engine
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Hi, Does anyone know of a PHP based search engine for a website? I was using Fluid Dynamics on my site - as I've got some sections of the site in a MySQL database, and some sections are just static pages. However, it seems to get stuck in a loop while trying to index portions of my database that are DATE formatted. Is it even possible to have a PHP search engine search a site that is mixed with MySQL and static pages? Thanks -Tim PHP from around 4.05 has functions available to interface with the mnoGOSearch search engine, available from http://www.mnogosearch.ru/ I recommend you look at this combination. -- David Robley Temporary Kiwi! Quod subigo farinam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP and search engine???
You check the $HTTP_USER_AGENT for what robot is going through your site. Yahoo, which gets their results from Google, would then have Googlebot somewhere in the var. To control webcrawlers more, you can look up robots.txt ( http://www.robotstxt.org/ ). --|-- Tino Didriksen http://ProjectJJ.dk/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]