Not the answer you need?
Register and ask your own question!
Many Forum changes were implemented on Tue 22 Sep. Read about new Ranks, Scoring, and Reactions.
Email [email protected] for any comments or concerns.

AND as the default modifier for boolean search

SpuerhundSpuerhund EntrantInactive User Role Beginner
I would like to offer my users the same behaviour that they are already used to. Let's take for example Google. Google has "AND" as the default operator, which means that you get less and less results with every word that you add to your first query.

In MySQL the default modifier is (according to the manual
http://dev.mysql.com/doc/refman/5.0/en/fulltext-boolean.html):
(no operator)
By default (when neither + nor - is specified) the word is optional, but the rows that contain it are rated higher. This mimics the behavior of MATCH() ... AGAINST() without the IN BOOLEAN MODE modifier.


That sounds nice, but acctually in most cases it just sucks. The result gets worse when you add another keyword to a one-word query and most users are confused when they now get results which didn't appear in the first result set, because they wanted to "filter" the first result even more.

Unfortunately, in all the years i haven't found a single user so far who was willingly to read the "HOW TO" explanation of my search function and went through a short crash course of boolean operators and "strange signs" (many don't even know where + and - are hiding on their keyboard). That's just a fact.

Therefore it would be very convenient to change the default operator to "+", so that without any given operator MySQL uses AND in case more than one word is given.

So far i haven't found a pure MySQL solution and it looks like i have to write my own query parser to split every query by "..." and (...) phrases, then by words, etc. and then add the missing "+" sign in front of every word without a modifier. Friendly, i am not eager to do that, as this should be done by the DB and not by some application logic on top.

What could be done? Any suggestions are welcome ... confused:

Comments

  • xaprbxaprb Mentor Inactive User Role Beginner
    I don't know of a way to do what you are looking for without altering the user's search query. I agree the default behavior is annoying.
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.