Re: keyword searching

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is my SQL query:

"SELECT seriesno, governor, descr, boxno, year, eyear, docno
from rg2 WHERE seriesno = '$_POST[seriesno]' and governor matches '*$searchterm*' or descr matches '*$searchterm*'";


So as you can see, its gonna need some work to make it do fulltext searching of the descr field. I'm not really sure how to make it do a keyword search, either since "holmes*north*carolina" doesn't work because it only searches for those words in that order, if descr field in the database contains "north carolina holmes" it won't return that result, but I want it to because the person using the db is looking for all the fields that contain holmes, north, and carolina.

CPT John W. Holmes wrote:
From: "Adam Williams" <awilliam@xxxxxxxxxxxxxxxx>

CPT John W. Holmes wrote:

From: "Adam Williams" <awilliam@xxxxxxxxxxxxxxxx>

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?

Are you doing a fulltext search or just matching a word in a lookup

column?


I'm doing a fulltext search.


What is your query? Assuming MySQL, I get a result like this:

mysql> select * from test where match(t) against ('holmes north carolina');
+--------------------------------------------+
| t                                          |
+--------------------------------------------+
| my name is john holmes from north carolina |
| i'm from the north                         |
| in carolina is my home                     |
| did I mention my last name is holmes?      |
+--------------------------------------------+
4 rows in set (0.01 sec)

Isn't that what you want?

---John Holmes...


-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux