gigablah/fsphinxphp

Sphinx 搜索的维度扩展

1.1.1 2013-10-04 04:49 UTC

This package is auto-updated.

Last update: 2024-08-24 04:15:14 UTC


README

FSphinx 是 [fSphinx] 1 Python 库的 PHP 版本,它扩展了 Sphinx API,以便轻松进行维度搜索。

什么是维度搜索?

想象一下“过滤”、“细化”或“深入”。例如,当搜索电影标题数据库时,你可以获得一个可点击的细化选项列表,如演员、导演、类型和发行年份。与静态的分层导航不同,维度是在搜索过程中计算的,因此你总是得到与当前查询术语相关的选项。

如何使用它?

您可以使用 [Composer] 2 将其集成到项目中。创建一个 composer.json 文件并运行 composer install

{
    "require": {
        "gigablah/fsphinxphp": "1.1.*"
    }
}

这会生成一个具有命名空间映射的自动加载器

require __DIR__ . '/vendor/autoload.php';
$fsphinx = new FSphinx\FSphinxClient();
$fsphinx->setServer('127.0.0.1', 9312);
$fsphinx->setDefaultIndex('items');
$fsphinx->setMatchMode(FSphinx\FSphinxClient::SPH_MATCH_EXTENDED2);
$fsphinx->attachQueryParser(new FSphinx\MultiFieldQuery());
$fsphinx->attachFacets(new FSphinx\Facet('actor'), new FSphinx\Facet('director'), new FSphinx\Facet('year'));
$results = $fsphinx->query('action');
foreach ($results['facets'] as $facet) print_r($facet);

如果您不使用 Composer,可以使用 fsphinxapi.php 来加载 FSphinx 类。

要了解更多信息,请参阅 [教程] 3 或 [文档] 4

要求

  • PHP 5.3+(命名空间、匿名函数)
  • Sphinx 1.10+(字符串属性)

作者

[Chris Heng] 5 hengkuanyen@gmail.com

许可

在 GNU LGPL 版本 3 下发布。有关详细信息,请参阅 LICENSE 文件。

致谢

此库基于 [Alex Ksikes] 6 的优秀工作。