Streaming Expressions can do this pretty easily. Checkout the rollup expression:
https://solr.apache.org/guide/8_6/stream-decorator-reference.html#rollup The example shows a rollup over the export handler results. to rollup over the top N just remove the qt=/export and it will use the /select handler. Joel Bernstein http://joelsolr.blogspot.com/ On Fri, Jun 3, 2022 at 8:24 AM Dave <hastings.recurs...@gmail.com> wrote: > Yeah, my first thought would be to have the first query with no facets and > a fl of just the id, limited to 1000, it’s a lot faster than you think if > you only return the id and no facets. Then do a secondary search for just > those ids and the facets added to that query using terms component as you > may run out of OR clauses. > > https://solr.apache.org/guide/6_6/the-terms-component.html > > > > > On Jun 3, 2022, at 7:52 AM, Noah Torp-Smith <n...@dbc.dk.invalid> wrote: > > > > If I have a solr with millions of documents, and a query results in > maybe 100000 hits, is there any way to get facet information for only the > first 1000 hits (for example) for that query? > > > > I googled and found a question from 11 years ago ( > https://solr-user.lucene.apache.narkive.com/AtnCbPV0/getting-facet-counts-for-10-000-most-relevant-hits#selection:3.655.119), > but the links there are not working any longer. I guess I could fetch the > 1000 documents and extract the documents on the client side, but I'd avoid > that if solr could do it for me. > > > > Thanks, > > > > /Noah > > > > > > -- > > > > Noah Torp-Smith (n...@dbc.dk) >