我正在尝试从索引文档的全文生成搜索摘录。我使用的是Sphinx 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。
发布于 2012-04-12 10:20:08
上面的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 );https://stackoverflow.com/questions/10116165
复制相似问题