I’m writing this because it needs to be written down somewhere. It’s an issue that’s almost ungoogleable because the only terms I could think of were “Or” and “And”, both of which google omits.
Also I’m just really annoyed I had to fix it in the first place
As you may or may not know, Magento (or at least CE 1.5) selects search results by searching through the database and selecting all items that have the user-selected keywords in the ‘searchable’ fields. In short, it uses OR logic. This is absolutely the worst way to do a search.
Let me explain why. Let’s say that I’m running a search on a store that sells a variety of sweets. Lets say I was trying to find something with chocolate and orange marmalade. The search query I’d use is “chocolate and orange marmalade”. Using OR logic like Magento is set up to use would show me a set of results that would include everything that includes or tastes like chocolate, everything with marmalade, everything that has or tastes like oranges, things that are described as orange-colored, and, worst of all, everything with the word “and” in the description. How much money has the site’s owner lost in lost sales because of this?
The solution is to switch from OR logic to AND logic. AND logic is what practically every mass-market focused search engine ever made uses by default. Using AND logic on the above example would only give me results that contained all three (technically four) keywords I typed in, giving me results that are actually relevant to what I was looking for, such as Lindt’s Intense Orange chocolate bar. The store owner will be happy because he just made that sale, and the customer will be happy because he found what he was looking for.
Luckally, the solution is easy to implement. Unfortunately, though, it requires you to edit the core source files, which is a big no if you ever plan to upgrade.
Simply change the two mentions of
' OR '
in app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php and it will switch to AND logic.
' AND '
Naturally, since you are editing the core source files, it will be deleted once you upgrade magento. If there’s anyway to use an override file or the likes, I would be appreciative.
P.S., in my 1.5, they were on lines 353 and 345