Is there a 开发者_StackOverflowway to limit the Result Set by the best N results? If I use Zend_Search_lucene::setResultSetLimit(10)
I will only get any 10 results and not the 10 best results according to my sorting declaration.
For your purpose you can't use
Zend_Search_lucene::setResultSetLimit(N)
because it gives you just the first N elements.
Limiting the Result Set
The most computationally expensive part of searching is score calculation. It may take several seconds for large result sets (tens of thousands of hits).
Zend_Search_Lucene gives the possibility to limit result set size with getResultSetLimit() and setResultSetLimit() methods:
$currentResultSetLimit = Zend_Search_Lucene::getResultSetLimit();
Zend_Search_Lucene::setResultSetLimit($newLimit);
The default value of 0 means 'no limit'.
It doesn't give the 'best N' results, but only the 'first N'.
How can you search for just 10 results and define them as best? You must search the entire index to determine the best results.
By default, the search results are ordered by score. Have a look at the documentation http://framework.zend.com/manual/1.11/en/zend.search.lucene.searching.html
By the way, whatever you are doing with zend lucene, think about using an other search engine like Solr. I use it in many projects and I recommend to use it. It is much faster and better to manage. To use it in a zend framework project you have to use a solr php client.
精彩评论