John thegimper wrote:
This is what i need:
Posted by gogman on Monday May 5 2003, @10:42am on the mysql website:
----------------------------
MySQL defaults to an 'OR'. Example: 'dog cat' = 'dog OR cat'. Most fulltext
search engines default to an 'AND'. These include: AltaVista, Fast Search,
Google, Hotbot, Lycos, Northern Light and Yahoo. Excite is an exception that
defaults to an 'OR'.
It's not clear to me that this is entirely accurate (Google, for example, is
a relevance search
<http://www.google.com/support/bin/answer.py?answer=427&topic=352>), but I
don't think web search engine front ends are particularly relevant in any case.
New Feature: set-variable = ft_boolean_default='AND'
vs 'OR'
('OR' would be the default setting so as to not break older code)
With a 'AND' default 'OR' would have to be explicit. Example: 'dog cat' = 'dog
AND cat', 'dog OR cat' - requires 'OR' to be set.
Performance tests are indicating a 5-7 times increase in search speed
with "AND" vs "OR" statements.
----------------------------------------------
I have done some searches on google and found several people wanting to do the
same... but no solutions.
Is there still no solution for this? Every large searchengine works like
this.
Why do you *need* this? More to the point, why should mysql do this?
Honestly, I think you are confusing the user interface, the application, and
the back end. Your user interface is free to include a search box where the
user can type 'dog cat' with the expectation that only documents containing
both (AND) will be returned. Your application needs to parse the request
and send the proper query to mysql (the back end). Mysql is just a useful
tool. It stores your data and provides various forms of full-text searching:
Relevance scoring -
WHERE MATCH (doc, description) AGAINST ('dog cat')
OR searches -
WHERE MATCH (doc, description) AGAINST ('dog cat' IN BOOLEAN MODE)
AND searches -
WHERE MATCH (doc, description) AGAINST ('+dog +cat' IN BOOLEAN MODE)
Given these choices, I'm not sure what difference it makes what the default
is. You surely don't propose to pass unmodified user input to mysql, as
that's not a good idea (see SQL injection
<http://www.google.com/search?q=SQL+injection>). If you want AND searches,
simply have your app add the + signs to the user input as it builds the
query to send to mysql.
If you are determined to change mysql's default behavior, then Sergei has
already given a solution earlier in this thread: swap the '+' and ' ' in the
ft_boolean_syntax variable. The only objection raised to this was the
suggestion that if the user prepends a '+' to a word, it becomes optional
(OR instead of AND), but that's a moot point, as your app will, of course,
strip the '+' when parsing the user's input.
Michael
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]