SphinxSearch
SphinxSearch copied to clipboard
Manticorp_SphinxSearch for Magento
Manticorp_SphinxSearch
This extension integrates Sphinx Search with any Magento installation.
Based on Gfe/SphinxSearch with a few key improvements.
Information
Tested on Magento CE 1.9.1.0
Installation
- optional Turn off compilation
- Copy all the files into the root of your Magento Installation
- Log out of admin
- Log back in
- Flush all caches
- optional Turn on compilation
Setup
Sphinx
- Install Sphinx Search
- Modify
sphinx.conf.sampleto suit your needs - Launch Sphinx using the
searchdcommand
Magento
- Go to your magento backend
- Go to System > Configuration > Catalog > Sphinx Search Engine
- Turn on 'Enable Search' and 'Enable Index'
- Update your 'path to sphinx' (leave blank by default if it's in your system path)
- Apply weights to the necessary fields
- Exclude whatever fields you wish from attributes
- Edit the Server configuration if need be (if you set up Sphinx with the default settings, you won't need to do this)
- Run a catalogsearch_fulltext index
How it works
Magento Default Search
By default, Magento chucks all searchable attributes into one fulltext column on the catalogsearch_fulltext index, so you might end up with something like the following:
| fulltext_id | product_id | store_id | data_index |
|---|---|---|---|
| 940753 | 225439 | 9 | CPU Desc etc |
And magento just does a fulltext search against the data_index column with no weighting on any attributes and also includes things like weight, price, etc.
Sphinx Search
Sphinx Search overrides the fulltext index and creates a new index table that looks more akin to the following:
| product_id | store_id | name | name_attributes | category | sku | data_index |
|---|---|---|---|---|---|---|
| 12345678 | 9 | CPU | 3GHz CPU | Some | Category | Foo |
Spinx then creates its own index based on this table and stores it away. The most important parts of this table are the three extra columns name, name_attributes, sku and category.
- Name is just the product name
- Name_attributes contains the name + some attributes (configurable in admin)
- Category contains the category names
Using the magento backend, we can assign weights to these columns in terms of ranking search results.
Sphinx Server
The sphinx server is configured using the file /var/sphinx/sphinx.conf on Linux (tested on CentOS) and contains all sorts of goodies.
Sphinx search has several, much cleverer algorithms for performing searches. A short list of (enabled) features include:
- Query expansion
- Language parsing (detects plurals etc)
- Misspelling correction (barels => barrels)
- ‘Soundex’ queries (cot => cat)
As well as many other behind the scenes stuff. It also ranks searches higher when words appear at the beginning of a field.
For example, a search for ‘Dog’ puts 'dog kennel' before 'log dog'.
Common Problems
Sphinx
Sphinx won't work! It keeps saying I don't have permission to do whatever!
- SSH into your sever / open a terminal window.
- Navigate to the mentioned directory
- chmod 777 -R {directoryname}
My searches are return irrelevant results!
Change which attributes are chosen or play with the weights.