Hello, I am trying to put together a search that can use multiple words.
I will use english words for the example while the db uses utf8 for foreign languages.
So if I am looking for “new york city” as a keyword, I have the following code:
$select = "SELECT * FROM $db_name.$table_name
WHERE ('id' LIKE '%$keyword%' OR
'title' LIKE '%$keyword%' OR
'published' LIKE '%$keyword%' OR
'numpages' LIKE '%$keyword%' OR
'otherinf' LIKE '%$keyword%' OR
'subject' LIKE '%$keyword%' OR
'author' LIKE '%$keyword%' OR
'location' LIKE '%$keyword%' )";
but I have also found that I can look for “new york city” in a title, using fulltext, I have the following code:
$select2 = "SELECT *, MATCH(isbn,lang,city,title,published,otherinf,subject) AGAINST('$keyword*' IN BOOLEAN MODE) AS score FROM $db_name.$table_name
WHERE MATCH(isbn,lang,city,title,published,otherinf,subject) AGAINST('$keyword*' IN BOOLEAN MODE) order by score desc";
I have added the following to my test setup for the fulltext:
[mysqld]
ft_min_word_len=3
ft_stopword_file=“C:\\wamp\\bin\\mysqlstop.txt”
Is this correct to do?
The db currently has about 5,000 records and I assume that it may go to double that mostly using vartext.
I would like to ask which one of the above coding should I use if I want to do the search?:
- by using complete phrase
- individual words
Secondly, if I add another word that has nothing to do with the others, such as “pears new york city” will that still give me results according the method chosen?
I read somewhere that partial searches are not possible for word combinations, e.g. everything - > ever*
Although I am not sure if this is true.
Thanks