sphinxapi BuildExcerpts(创建高亮文本摘要) 方法参数说明

17-08-02 10:34 字数 1214 阅读 5151 已编辑

首先官方参数说明

public array SphinxClient::buildExcerpts ( array $docs , string $index , string $words [, array $opts ] )

$docs Array of strings with documents' contents.

$index Index name.

$words Keywords to highlight.

$opts 如下

Option Description
"before_match" A string to insert before a keyword match. Default is "".
"after_match" A string to insert after a keyword match. Default is "".
"chunk_separator" A string to insert between snippet chunks (passages). Default is " ... ".
"limit" Maximum snippet size, in symbols (codepoints). Integer, default is 256.
"around" How much words to pick around each matching keywords block. Integer, default is 5.
"exact_phrase" Whether to highlight exact query phrase matches only instead of individual keywords. Boolean, default is FALSE.
"single_passage" Whether to extract single best passage only. Boolean, default is FALSE.

中文解释

$docs 为包含各文档内容的数组。【注意!如果数组里里有int类型需要转换成string。如:(string) 1】

$index 为索引名。

$words 为包含需要高亮的关键字的字符串。

下面是$opts可选参数。

before_matchafter_match 就不说了,就是匹配的keyword前后要插入的字符串。

chunk_separator 在摘要词组(段落)之间插入的字符串。默认为" ... "。

limit 摘要最多包含的符号(codepoints)数。这个codeopints是什么意思具体可以百度下,不做深入说明,因为我也不太明白 。

around 每个关键词块左右选取的词的数量。整数,默认为 5.

exact_phrase 是否突出显示精确的查询短语匹配而不是单个关键字。布尔值,默认值为FALSE。【这货有点奇怪,在我使用coreseek时如果这个设置为true会导致无法高亮关键词,并抛出下面的异常received zero-sized searchd response

single_passage 是否仅提取匹配到的最佳的一个区块。布尔值,默认为false.

0人点赞>
关注 收藏 改进 举报
2 条评论
排序方式 时间 投票
myvic

我:'exact_phrase' => true

这个设置true,报下面错误,请问你解决了吗?

报错:searchd error: exact_phrase is deprecated, use phrase search operator with query_mode=1

Up骚年
这个参数被废弃了,不能用了。
请登录后发表评论
站长 @ 十七度
文章
380
粉丝
23
喜欢
191
收藏
31
排名 : 1
访问 : 128.24万
私信