【问题标题】:sphinx setlimits isn't working狮身人面像 setlimits 不起作用
【发布时间】:2013-07-29 00:29:37
【问题描述】:

我正在使用 sphinx,除了 SetLimits 之外,一切似乎都运行良好,我在索引中只有 3 条记录,当我使用 $cl->SetLimits(0,2) 时,它返回 2 个结果。 当我使用 $cl->SetLimits(1,2) 时,我也得到了 2,而当我使用 $cl->SetLimits(1,2) 时,我什么也没得到。

这是我对 setlimits 的理解

$cl->SetLimits(0,2);// should return the first two matches
$cl->SetLimits(1,2);// should return only one as I have only 3 records in the index
$cl->SetLimits(2,2);// should return nothing

这是我在数据库中插入的内容

insert into tindex values('1','test');
insert into tindex values('2','test');
insert into tindex values('3','test');

当我选择索引时我可以看到它。

php代码如下

$keywords = "test";
$index = "tindex"; 
$cl = new SphinxClient();
$cl->SetServer( "127.0.0.1", 9312 );
$cl->SetMatchMode( SPH_MATCH_ANY  );        
$cl->SetLimits(1,2);

$result = $cl->Query( $keywords, $index  );

if ( $result === false ) {
    echo "Query failed: " . $cl->GetLastError() . ".\n";
}
else {
    if ( $cl->GetLastWarning() ) {
        echo "WARNING: " . $cl->GetLastWarning() . "";
    }

    if ( ! empty($result["matches"]) ) {
        foreach ( $result["matches"] as $doc => $docinfo ) {

        } 
        print_r( $result );


    }
}

【问题讨论】:

  • 找到问题了,我第一个有问题,是偏移量而不是页码:)

标签: php sql database full-text-search sphinx


【解决方案1】:

我完全遵循这个原型:函数 Set Limits ( $offset, $limit, $max_matches=0, $cutoff=0 ) 来自http://sphinxsearch.com/docs/current.html#api-func-setlimits

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-15
    • 1970-01-01
    • 2014-01-09
    • 2015-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多