[PHP] keyword searching
Hello, I am selecting a field in a database called description for keyword searching. The field contains names of people, states, years, etc. When someone searches for say holmes north carolina the query searches for exactly that, fields which have holmes north carolina, and not fields that contaim holmes, north, and carolina. So I run a str_replace to replace all spaces with *, which turns it into holmes*north*carolina, but say that north carolina is before holmes in the field, it won't return those fields (it only returns fields in which holmes is infront of north carolina). So how can I have it return all fields which contain all the words holmes, north, and carolina in any order, in that field? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] keyword searching
[snip] I am selecting a field in a database called description for keyword searching. The field contains names of people, states, years, etc. When someone searches for say holmes north carolina the query searches for exactly that, fields which have holmes north carolina, and not fields that contaim holmes, north, and carolina. So I run a str_replace to replace all spaces with *, which turns it into holmes*north*carolina, but say that north carolina is before holmes in the field, it won't return those fields (it only returns fields in which holmes is infront of north carolina). So how can I have it return all fields which contain all the words holmes, north, and carolina in any order, in that field? [/snip] You don't say which database you are using, but several allow for full text searching of fields where the order is inconsequential. The behaviour you describe is preceisely how most (if not all) databases will return a search on a standard column type. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] keyword searching
I'm using Informix SQL. Do you know how to do full text searching on Informix? If so, please share the details :) Jay Blanchard wrote: [snip] I am selecting a field in a database called description for keyword searching. The field contains names of people, states, years, etc. When someone searches for say holmes north carolina the query searches for exactly that, fields which have holmes north carolina, and not fields that contaim holmes, north, and carolina. So I run a str_replace to replace all spaces with *, which turns it into holmes*north*carolina, but say that north carolina is before holmes in the field, it won't return those fields (it only returns fields in which holmes is infront of north carolina). So how can I have it return all fields which contain all the words holmes, north, and carolina in any order, in that field? [/snip] You don't say which database you are using, but several allow for full text searching of fields where the order is inconsequential. The behaviour you describe is preceisely how most (if not all) databases will return a search on a standard column type. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] keyword searching
From: Adam Williams [EMAIL PROTECTED] I'm using Informix SQL. Could have saved some bandwidth by mentioning that in the first place and only posting to either php-general or php-db (which is more appropriate), not both. :) Ignore what my other posts said, as I don't know how Informix works. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php