伍佰目录 短网址
  当前位置:海洋目录网 » 站长资讯 » 站长资讯 » 文章详细 订阅RssFeed

PHP - Manual: SphinxClient::setLimits

来源:网络转载 浏览:49861次 时间:2024-06-02
SphinxClient::setMatchMode » « SphinxClient::setIndexWeights
  • PHP 手册
  • 函数参考
  • 搜索引擎扩展
  • Sphinx
  • SphinxClient

SphinxClient::setLimits

(PECL sphinx >= 0.1.0)

SphinxClient::setLimits — 设置返回结果集偏移量和数目

说明

public SphinxClient::setLimits ( int $offset , int $limit [, int $max_matches = 0 [, int $cutoff = 0 ]] ) : bool

给服务器端结果集设置一个偏移量 offset 从那个偏移量起向客户端返回的匹配项数目限制(limit) . 并且可以在服务器端设定当前查询的结果集大小 (max_matches) ,另有一个阈值 (cutoff),当找到的匹配项达到这个阀值时就停止搜索。

参数

offset

结果集的偏移量.

limit

返回的匹配项数目.

max_matches

设置控制搜索过程中searchd在内存中所保持的匹配项数目.

cutoff

该设置是为高级性能优化而提供的. 它告诉searchd 在找到并处理 cutoff 个匹配后就强制停止.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

add a note

User Contributed Notes 4 notes

up down 1 xxxbunker dot com9 years ago the max_matches / cutoff parameters are priceless.

if you ever have a situation where you need a 'count' of the number of matches, but only need to display lets say the 'top 10', these 2 parameters are very handy.

we used to get the occasional 'unable to connect' error with sphinx, after implementing these 2 parameters where applicable, these issues disappeared, load dropped, and the servers were much happier.
up down 0 vlk dot abakan at gmail dot com3 years ago If you use shpinxQL, you can add "max_matches" option to your query:

<?php
   SELECT ... LIMIT 1000, 10 OPTION max_matches = 1000
?>

And to "searchd" section in sphinx.conf:

<?php

searchd {
    ...
    max_matches = 10000
    ....
}

?>
up down 0 shoanm at users dot sourceforge dot net9 years ago I almost pulled out all my hair trying to figure this one out. After applying limits using

$s->setLimit(10,10);

the search kept returning only false. getLastError() and getLastWarning() contained empty strings.

The solution, like Nayana stated, is to add a positive non-zero integer $max to setLimit.
up down 0 Nayana Hettiarachch nayana at corp-gems dot com10 years ago If you get an error
per-query max_matches=0 out of bounds (per-server max_matches=1000).

make sure that you also set the $max to a value other than the default 0,

there is an issue published with a patch if you feel like wanting to patch,

the first option works well as a workaround.

http://sphinxsearch.com/bugs/view.php?id=208
add a note

官方地址:https://www.php.net/manual/en/sphinxclient.setlimits.php

  推荐站点

  • At-lib分类目录At-lib分类目录

    At-lib网站分类目录汇集全国所有高质量网站,是中国权威的中文网站分类目录,给站长提供免费网址目录提交收录和推荐最新最全的优秀网站大全是名站导航之家

    www.at-lib.cn
  • 中国链接目录中国链接目录

    中国链接目录简称链接目录,是收录优秀网站和淘宝网店的网站分类目录,为您提供优质的网址导航服务,也是网店进行收录推广,站长免费推广网站、加快百度收录、增加友情链接和网站外链的平台。

    www.cnlink.org
  • 35目录网35目录网

    35目录免费收录各类优秀网站,全力打造互动式网站目录,提供网站分类目录检索,关键字搜索功能。欢迎您向35目录推荐、提交优秀网站。

    www.35mulu.com
  • 就要爱网站目录就要爱网站目录

    就要爱网站目录,按主题和类别列出网站。所有提交的网站都经过人工审查,确保质量和无垃圾邮件的结果。

    www.912219.com
  • 伍佰目录伍佰目录

    伍佰网站目录免费收录各类优秀网站,全力打造互动式网站目录,提供网站分类目录检索,关键字搜索功能。欢迎您向伍佰目录推荐、提交优秀网站。

    www.wbwb.net