ZF-10968: When using setResultLimit you get not top rated results

Issue Type: Bug Created: 2011-01-20T00:44:37.000+0000 Last Updated: 2011-01-20T00:44:37.000+0000 Status: Open Fix version(s): Reporter: Andrey Petrenko (seriousdron) Assignee: Alexander Veremyev (alexander) Tags: - Zend_Search_Lucene

Related issues: Attachments:


Search with $index->setResultSetLimit(4); and without gives different results. Most top (and that right) result in full search does not list at all in limited resultset. Didn't actually test, but as i can see there is still that problem in repo. Problem located in Zend/Search/Lucene.php, sorting is later than fetching limit, so it gets not top hits, but random one.

foreach ($query->matchedDocs() as $id => $num) { $docScore = $query->score($id, $this); if( $docScore != 0 ) { $hit = new Zend_Search_Lucene_Search_QueryHit($this); $hit->id = $id; $hit->score = $docScore;

    $hits[]   = $hit;
    $ids[]    = $id;
    $scores[] = $docScore;

    if ($docScore > $topScore) {
        $topScore = $docScore;

// LIMIT IS HERE if (self::$_resultSetLimit != 0 && count($hits) >= self::$_resultSetLimit) { break; } }

if (count($hits) == 0) { // skip sorting, which may cause a error on empty index return array(); }

if ($topScore > 1) { foreach ($hits as $hit) { $hit->score /= $topScore; } } //SORTING IS HERE if (func_num_args() == 1) { // sort by scores array_multisort($scores, SORT_DESC, SORT_NUMERIC, $ids, SORT_ASC, SORT_NUMERIC, $hits);


No comments to display

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.