One other thing you'll need to watch out for is the filterCache ... Solr has a setting (i forget the name at the moment) which tells the SolrIndexSearcher that for sorted queries, it can reuse the DocSet from a previous invocation of the Query and sort the cached DocSet to generate the list -- but your set of documents returned is dependent on your sort order, so you may actually want to put the sort option in your TrimmedQuery as well to denote the uniqueness of the set of matched Documents.
if you think about it, a completley generalized solution would allow the "trimming" order to be independent of the sorting order, so a user could ask for "Books matching the word 'Lucene' trimmed so only the most popular matching book per publisher is returned, sorted by price." .. in which case your Query needs to know that "Publisher" i the field you grouped on, and "Popularity"/"desc" is the trimming you applied to each group --and now the usual DocList and DocSet caching will work flawlessly, regardless of the fact that you sorted on "Price" this time, but next time you might sort on "Popularity". : Date: Wed, 15 Nov 2006 19:26:39 -0500 : From: Yonik Seeley <[EMAIL PROTECTED]> : Reply-To: solr-user@lucene.apache.org : To: solr-user@lucene.apache.org : Subject: Re: Trimming the list of docs returned. : : On 11/15/06, Tom <[EMAIL PROTECTED]> wrote: : > >One hack: implement a simple query that delegates to another query and : > >encapsulates the trim value... that way hashCode/equals won't match : > >unless the trim does. : > : > Not sure what you mean by "delegates to another query". Could you : > clarify or give me a pointer? : : Something like : public class TrimmedQuery extends Query { : Query delegate; : public TrimmedQuert(Query delegate, int trim) { : this.delegate = delegate; : } : // now override hashCode + equals to include trim and implement all other : // methods by delegating them. : } : : > I was thinking in terms of just adding some guaranteed true clause to : > the end when trimming, is that similar to what you were talking about? : : Yes, that should work too. : : -Yonik : -Hoss