On 23 Nov 2005, at 18:37, Alan Chandler wrote:
My home page wants to have a summary of perhaps the most recent five blogs
entries.

Personifying your home page... cute :)

It looks as though I can use the Datefield class to store the publication date in an orderable form - so that I can effectively do a ordered search using
this field as the sort field.

Is there anyway to limit the number of hits returned in the search to 5 (or does it not generate any storage overhead to return them all and just use the
first 5)

I recommend against using DateField, because it's granularity is down to the millisecond and has some nuances to it, but there are a few options to doing what you want. Use a date field as YYYYMMDD format instead (unless you need a time also).

1) Documents in Lucene are in order of insertion, so if you're inserting them in chronological order, you could simply direct access the last five documents without a search. 2) There is no (well, minimal) storage overhead in doing a full search and only getting the most recent 5 documents, provided you sort the search by the date field. 3) There are expert-level search() methods that do allow limiting to N number of results, but that isn't really necessary (see javadocs for details - they literally are marked as "expert").

        Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to