lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: Hits and TopDoc
Date Tue, 20 Oct 2009 22:20:22 GMT
That update to the Hits javadoc didn't make 2.9.0, but will be in
2.9.1 (it's committed to the 2.9.x branch now).

Mike

On Tue, Oct 20, 2009 at 6:00 PM, Steven A Rowe <sarowe@syr.edu> wrote:
> Hi Yonik,
>
> Hmm, in what version of Hits do you see this updated javadoc?  In the 2.9.0 version,
the only change in the Hits javadoc from the 2.4.1 version in this section is that it refers
to TopScoreDocCollector instead of TopDocCollector:
>
> http://lucene.apache.org/java/2_9_0/api/core/org/apache/lucene/search/Hits.html
>
> And, of course, Hits has now been removed from trunk as part of the deprecation cleansing
ritual.
>
> Steve
>
> On 10/20/2009 at 5:43 PM, Yonik Seeley wrote:
>> Hmm, yes, I should have thought of quoting the havadoc :-)
>> The Hits javadoc has been udpated though... we shouldn't be pushing
>> people toward collectors unless they really need them:
>>
>>  *   TopDocs topDocs = searcher.search(query, numHits);
>>  *   ScoreDoc[] hits = topDocs.scoreDocs;
>>  *   for (int i = 0; i < hits.length; i++) {
>>  *     int docId = hits[i].doc;
>>  *     Document d = searcher.doc(docId);
>>  *     // do something with current hit
>>
>>
>> -Yonik
>> http://www.lucidimagination.com
>>
>>
>>
>> On Tue, Oct 20, 2009 at 5:27 PM, Steven A Rowe <sarowe@syr.edu> wrote:
>> > Hi Nathan,
>> >
>> > On 10/20/2009 at 5:03 PM, Nathan Howard wrote:
>> >> This is sort of related to the above question, but I'm trying to
>> update
>> >> some (now depricated) Java/Lucene code that I've become aware of
>> once we
>> >> started using 2.4.1 (we were previously using 2.3.2):
>> >>
>> >> Hits results = MultiSearcher.search(Query));
>> >>
>> >> int start = currentPage * resultsPerPage;
>> >> int stop = (currentPage + 1) * resultsPerPage();
>> >>
>> >> for(int x = start; (x < searchResults.length()) && (x < stop);
x++)
>> >> {
>> >>     Document doc = searchResults.doc(x);
>> >>     // do search post-processing with the Document
>> >> }
>> >>
>> >> Results per page is normally small (10ish or so).
>> >>
>> >> I'm having difficulty figuring out how to get TopDocs to replicate
>> this
>> >> paging functionality (which the application must maintain).
>> >
>> > From
>> <http://lucene.apache.org/java/2_4_1/api/core/org/apache/lucene/search/
>> Hits.html>:
>> > =====
>> > Deprecated. Hits will be removed in Lucene 3.0.
>> >
>> > Instead e. g. TopDocCollector and TopDocs can be used:
>> >
>> >   TopDocCollector collector = new TopDocCollector(hitsPerPage);
>> >   searcher.search(query, collector);
>> >   ScoreDoc[] hits = collector.topDocs().scoreDocs;
>> >   for (int i = 0; i < hits.length; i++) {
>> >     int docId = hits[i].doc;
>> >     Document d = searcher.doc(docId);
>> >     // do something with current hit
>> >     ...
>> > =====
>> >
>> > Construct the TopDocCollector with your "stop" variable instead of
>> "hitsPerPage", initialize the loop control variable with the value of
>> your "start" variable instead of 0, and you should be good to go.
>> >
>> > Steve
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message