【问题标题】:How do I generate document excerpts using Sphinx and the Sphinx PHP API?如何使用 Sphinx 和 Sphinx PHP API 生成文档摘录?
【发布时间】:2012-04-12 01:15:02
【问题描述】:

我正在尝试从索引文档的全文中生成搜索摘录。我正在使用狮身人面像 V2.02。我的 Sphinx 索引工作正常,常规结果也没有问题。

我正在从磁盘加载文档,因此我将load_files 设置为 TRUE。我已经尝试了文件的 web 路径和直接的 Linux 文件路径。

这是我的摘录代码:

$options = array( 'load_files' => TRUE );
$docs = array( /files/0/123/123.txt );
$words = 'gears';
$excerpts = $sphinxclient->BuildExcerpts( $docs, 'files', $words, $options );

这里是Sphinx Documentation for Generating Excerpts

BuildExcerpts 每次都返回 false,而不是返回摘录。发生了什么?我是否应该在常规查询的同时以某种方式执行此操作?我一直在对从主查询返回的每个文档执行BuildExcerpts

【问题讨论】:

    标签: search sphinx


    【解决方案1】:

    上面 BuildExcertps 的代码是正确的。

    问题是我的“文件”索引是分布式的,Sphinx BuildExcerpts 调用不喜欢那样。 BuildExcerpts 似乎实际上只是引用该索引的配置,因此您必须引用实际索引之一,而不是 BuildExcerpts() 调用中的分布式索引。

    例如:我将文件索引分为 5 个碎片、files_0、files_1 等。使用“files”作为索引会破坏 BuildExcerpts。使用 files_0 或我的任何分片都可以正常工作。

    $options = array( 'load_files' => TRUE );
    $docs = array( /files/0/123/123.txt );
    $words = 'gears';
    $excerpts = $sphinxclient->BuildExcerpts( $docs, 'files_0', $words, $options );
    

    【讨论】:

      猜你喜欢
      • 2018-06-12
      • 2018-03-02
      • 1970-01-01
      • 2012-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-23
      相关资源
      最近更新 更多