I am planning on setting up a filter system (refine your search) in my ecommerce stores. You can see an example here: http://www.bettymills.com/shop/product/find/Air+and+HVAC+Filters
Platforms such as PrestaShop, OpenCart and Magento have what's called a Layered Navigation.
My question is what is the difference between the Layered Navigation in platforms such as Magento or PrestaShop in comparison to using something like Solr or Lucene for faceted navigation.
Can a similar result be accomplished via just php and mysql?
A detailed explanation is much appreciated.
out of the solr box, you can use calculated facet, range, choose a facet or exclude one, declare if a facet is mono valued, or multi valued with a very low cpu/ram cost
On the other hand, it takes some time to parameter and secure the solr installation, it also takes some time to crawl your data.
Magento Enterprise Edition has an implementation of Solr with faceted search. Still you need to configure Solr to index the correct data; i.e. Solr runs on Java on a host with a specific port. Magento connects to it through a given url. When Magento sets up the faceted search, it does a request to Solr and processes the received xml into a form on the frontend. The difference would be one of speed. Requesting to Solr is very fast. If you have about 100,000+ products in your shop and want quick responses on search requests, you can use Solr. But still, if you have a separate server for the Magento database with a lot of memory, you can also just use Magento's built in Mysql based faceted search. If you don't have money to spend on Magento EE, you can use this solr implementation. But I do not have any experience with this one.
Layered Navigation == Faceted Search.
They are the same thing, but Magento and al uses different wording, probably to be catchy. As far as I know, Magento supports both the Solr faceted search or the MySQL one. The main difference is the performance.
Performance is the main trade-off.
To do faceted search in MySQL requires you to join tables, while Solr indexes the document facets automatically for filtering. You can generally achieve fast response times using Solr (<100ms for a multi-facet search query) on average hardware. While MySQL will take longer for the same search, it can be optimized with indexes to achieve similar response times.
The downside to Solr is that it requires you to configure, secure and run yet another service on your server. It can also be pretty CPU and memory intensive depending on your configuration (Tomcat, jetty, etc.).
Faceted search in PHP/MySQL is possible, and not as hard as you'd think.
You need a specific database schema, but it's feasible. Here's a simple example:
product
classification
product_classification
So, say someones search for
paint
, you'd do something like:This would return both entries from the
product
table.Once your search has executed, you can fetch the associated facets (filters) of your result using a query like this one:
This'll give you something like:
So, in your result set, you know that there are products whose color are
blue
andred
, that the only material it's made from islatex
, and that it can be found in departmentshome
andpaint
.Once a user select a facet, just modify the original search query:
So, here the user is searching for keyword
paint
, and includes two facets: facetblue
for color, andhome
for department. This'll give you:So, in conclusion. Although it's available out-of-the-box in Solr, it's possible to implement it in SQL fairly easily.
You can created faceted search with just PHP and MySQL, Drupal Faceted Search is a good example. But if you already use Solr, you get faceted search included for free.