I couldn't find much on the variable you were trying to change. Although it may have changed and now be called ft_boolean_syntax. But that still won't help you since it doesn't appear to have an option to change the default separator.
I think you will need to add the + to each word if you want the AND behavior. Why are you so averse to parsing? It would make it easier for the user to input search terms.


If it's helpful, below is some php code I use for parsing search phrases entered by users. It adds + and * based on quotes or independent words. I wrote it a long time ago and it problem needs to be looked at to make it better, but it's worked for me for a while now. It will give you the AND behavior you are looking for.

function prepFullTextSearch($searchVal) {
//Split words into list
$word_List = explode(' ',trim($searchVal));
//Step through word list to get search phrases
$i = 0;
$isPhrase = false;
foreach($word_List as $word) {
$searchItems[$i] = trim( ($isPhrase?$searchItems[$i].' '.$word:$word) );
//Check for start of Phrase
if(substr($searchItems[$i],0,1) == '"') {
$isPhrase = true;
}
//If not building a phrase, append wildcard (*) to end of word
if(!$isPhrase) {
$searchItems[$i] .= '*';
$i++;
}
//Check for end of Phrase
if(substr($searchItems[$i],-1) == '"') {
$isPhrase = false;
$i++;
}
}
$searchVal = '+'.implode(' +',$searchItems);
return $searchVal;
}



On Mar 23, 2005, at 2:45 PM, Jessica Svensson wrote:

Is there any way i can get results with AND instead of OR?
Trying to search for "black cat" should only return records that contains both black and cat.


I'm using the following code to get my result:

SELECT * FROM `searchtbl` WHERE MATCH (text) AGAINST ('black cat' IN BOOLEAN MODE);

sure there must be an easy way to change the default word separator to AND instead of OR?

I found this:
set-variable = ft_boolean_default='AND'
SET ft_boolean_default = 'AND'
But it does not work, everything would be sooo much easier if this was possible.


"black cat" is only an example and the real query comes from user input. So it can be anything like +cat -dog +"big nose" -horse white black -red
so parsing the input is not what i want, i just want to change the default word separator to AND instead of OR.


Now i´m running 4.1.10 and also tried with 4.0.24

Please help me, there must be a way to change this?!?!

_________________________________________________________________
Hitta rätt på nätet med MSN Sök http://search.msn.se/


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to