The functionality you are describing is called "Faceting" in Solr and can be achieved with a single query, take a look at the following wiki pages for more info:
http://wiki.apache.org/solr/SolrFacetingOverview http://wiki.apache.org/solr/SimpleFacetParameters In regards to faceting date fields such as publish_date, take a look at https://issues.apache.org/jira/browse/SOLR-258 which was recently commited to the svn trunk (although not much documentation on that yet). Just a note about your query, specifying the sort order in the q parameter is depricated syntax, you are better to use the sort parameter for that, again refer to the wiki: http://wiki.apache.org/solr/CommonQueryParameters Hope this helps, Piete On 07/08/07, Yu-Hui Jin <[EMAIL PROTECTED]> wrote: > > Hi, there, > > We used Solr to index a set of documents and provide free-text search > functionality with sorting options on a number of fields. We have a > requirement that along with each search result we want to obtain the > ranges > of a few fields for the resulting documents. Here's an example: > > Let's say we indexed documents representing books with the following > fields: > > title, price, publish_date, description > > All of these fields are stored in the index (that can be returned); and > "price" and "publish_date" are sortable as well. > > Now suppose we post a query for example "title:art history;price asc", we > want to the following results: > > 1. the documents satisfying the query (which by default are returned by > solr); > 2. the range of the price field of the results. > 3. the range of the publish_date of the results. > > My question is -- can solr return all of the above data within one > response? If not, all I can think of is to issue one more query that > "title:art history;publish_date asc" (or desc) so that I can use the first > and last result of this query to get the range for publish_date. (Due to > the original query already asking to sort by price, we are lucky in this > case that we don't have to issue another query to get the range of price. > But then this does not apply in the general case.) > > Any idea is appreciated! > > -- > Regards, > > -Hui >