FSphinx is a PHP port of the [fSphinx] 1 Python library, which extends the Sphinx API to easily perform faceted search.
Think of "filtering", "refining" or "drilling down". For example, when searching through a database of movie titles, you could get a list of clickable refinement options such as actors, directors, genre and year of release. As opposed to static hierarchical navigation, these options are calculated as you search so you don't end up following paths that return zero results.
$fsphinx = new FSphinxClient();
$fsphinx->SetServer(SPHINX_HOST, SPHINX_PORT);
$fsphinx->SetDefaultIndex('movies');
$fsphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
$fsphinx->AttachQueryParser(new MultiFieldQuery());
$fsphinx->AttachFacets(new Facet('actor'), new Facet('director'), new Facet('year'));
$results = $fsphinx->Query('action');
foreach ($results['facets'] as $facet) var_dump($facet);
To learn more, please refer to the [tutorial] 2 or the [documentation] 3.
- PHP 5.3+ (namespaces, anonymous functions)
- Sphinx 1.10+ (string attributes)
For questions and suggestions, please email Chris Heng (hengkuanyen at gmail dot com).